workflows: allow complex data in webservice calls (#49697)

This commit is contained in:
Frédéric Péters 2020-12-22 17:14:11 +01:00
parent 9444fa214a
commit f793d4cf5c
2 changed files with 14 additions and 7 deletions

View File

@ -2227,8 +2227,8 @@ def test_webservice_with_complex_data(http_requests, pub):
'ezt_items': 'aa, bb',
'item_raw': 'a',
'ezt_item_raw': 'a',
'items_raw': "['a', 'b']",
'ezt_items_raw': "['a', 'b']",
'items_raw': ['a', 'b'],
'ezt_items_raw': ['a', 'b'],
}

View File

@ -113,11 +113,18 @@ def call_webservice(
# if post_data exists, payload is a dict built from it
if method in ('PATCH', 'PUT', 'POST') and post_data:
payload = {}
for (key, value) in post_data.items():
try:
payload[key] = WorkflowStatusItem.compute(value, raises=True)
except:
get_publisher().notify_of_exception(sys.exc_info())
with get_publisher().complex_data():
for (key, value) in post_data.items():
try:
payload[key] = WorkflowStatusItem.compute(value,
allow_complex=True, raises=True)
except:
get_publisher().notify_of_exception(sys.exc_info())
else:
if payload[key]:
complex_value = get_publisher().get_cached_complex_data(payload[key])
if complex_value:
payload[key] = complex_value
# if formdata has to be sent, it's the payload. If post_data exists,
# it's added in formdata['extra']