Commit dd10ac56 authored by Titouan Soulard's avatar Titouan Soulard

erp5_json_form: fix raises on validation errors and when missing after method

parent b032c93c
......@@ -63,14 +63,14 @@ class JSONForm(JSONType, TextDocument):
)
def __call__(self, json_data, list_error=False): #pylint:disable=arguments-differ
validation_result = self.validateJSON(json_data, list_error)
data_dict = json.loads(json_data)
validation_result = self.validateJSON(data_dict, list_error)
if validation_result is not True:
if not list_error:
raise jsonschema.exceptions.ValidationError(validation_result.message)
else:
raise ValueError(json.dumps(validation_result))
data_dict = json.loads(json_data)
if self.getAfterMethodId():
after_method = getattr(getattr(self, "aq_parent", None), self.getAfterMethodId())
mapped_data_dict = self._mapArguments(data_dict, "input")
......@@ -82,7 +82,7 @@ class JSONForm(JSONType, TextDocument):
mapped_output_dict = self._mapArguments(output_dict, "output")
return json.dumps(mapped_output_dict)
return "Nothing to do"
raise NotImplementedError("No after method")
def _mapArguments(self, arguments, mapping_type):
mappings = {x.getSource(): x.getDestination() for x in self.objectValues(portal_type="Argument Mapping") if x.getMappingType() == mapping_type}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment