general: always post-process complex values (#50202)

This commit is contained in:
Frédéric Péters 2021-01-16 12:33:30 +01:00
parent cc1a6a112b
commit 595faf0d0d
4 changed files with 18 additions and 9 deletions

View File

@ -2219,6 +2219,12 @@ def test_webservice_with_complex_data(http_requests, pub):
data_source=datasource),
StringField(id='3', label='3rd field',
type='str', varname='str'),
StringField(id='4', label='4th field',
type='str', varname='empty_str'),
StringField(id='5', label='5th field',
type='str', varname='none'),
BoolField(id='6', label='6th field',
type='bool', varname='bool'),
]
formdef.workflow_id = wf.id
formdef.store()
@ -2232,6 +2238,9 @@ def test_webservice_with_complex_data(http_requests, pub):
formdata.data['2_display'] = 'aa, bb'
formdata.data['2_structured'] = formdef.fields[1].store_structured_value(formdata.data, '2')
formdata.data['3'] = 'tutuche'
formdata.data['4'] = 'empty_str'
formdata.data['5'] = None
formdata.data['6'] = False
formdata.just_created()
formdata.store()
@ -2254,6 +2263,9 @@ def test_webservice_with_complex_data(http_requests, pub):
'str': '{{ form_var_str }}',
'str_mod': '{{ form_var_str }}--plop',
'decimal': '{{ "1000"|decimal }}',
'empty_string': '{{ form_var_empty }}',
'none': '{{ form_var_none }}',
'bool': '{{ form_var_bool_raw }}',
}
pub.substitutions.feed(formdata)
with get_publisher().complex_data():
@ -2277,6 +2289,9 @@ def test_webservice_with_complex_data(http_requests, pub):
'str': 'tutuche',
'str_mod': 'tutuche--plop',
'decimal': '1000',
'empty_string': '',
'none': None,
'bool': False,
}
# check it's possible to disable complex data support

View File

@ -136,9 +136,7 @@ class SetBackofficeFieldsWorkflowStatusItem(WorkflowStatusItem):
except Exception:
continue
if formdef_field.allow_complex:
complex_value = get_publisher().get_cached_complex_data(new_value)
if complex_value:
new_value = complex_value
new_value = get_publisher().get_cached_complex_data(new_value)
if formdef_field.convert_value_from_anything:
try:

View File

@ -420,9 +420,7 @@ class CreateFormdataWorkflowStatusItem(WorkflowStatusItem):
# already logged by self.compute
continue
if dest_field.allow_complex:
complex_value = get_publisher().get_cached_complex_data(value)
if complex_value:
value = complex_value
value = get_publisher().get_cached_complex_data(value)
try:
self._set_value(

View File

@ -122,9 +122,7 @@ def call_webservice(
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
payload[key] = get_publisher().get_cached_complex_data(payload[key])
# if formdata has to be sent, it's the payload. If post_data exists,
# it's added in formdata['extra']