Commit 568cc9ff authored by iv's avatar iv

ERP5Workflow: use getAfterScriptValueList and getBeforeScriptValueList

instead of getXXXScriptIdList, which calls getXXXScriptValueList anyway (-> bad performances)
parent 1a3d26d1
......@@ -597,16 +597,18 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
# Execute the "before" script.
before_script_success = 1
if tdef is not None and tdef.getBeforeScriptIdList():
script_id_list = tdef.getBeforeScriptIdList()
if tdef is not None:
script_value_list = tdef.getBeforeScriptValueList()
if script_value_list:
kwargs = form_kw
sci = StateChangeInfo(
document, self, former_status, tdef, old_sdef, new_sdef, kwargs)
for script_id in script_id_list:
script = self._getOb(script_id)
sci = StateChangeInfo(document, self, former_status, tdef, old_sdef,
new_sdef, kwargs)
for script in script_value_list:
# Pass lots of info to the script in a single parameter.
if script.getPortalType() != 'Workflow Script':
raise NotImplementedError ('Unsupported Script %s for state %s'%(script_id, old_sdef.getReference()))
raise NotImplementedError ('Unsupported Script %s for state %s' %
(script.id, old_sdef.getReference()))
try:
script(sci) # May throw an exception.
except ValidationFailed, validation_exc:
......@@ -692,17 +694,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
# Execute the "after" script.
if tdef is not None:
script_id_list = tdef.getAfterScriptIdList()
if script_id_list:
script_value_list = tdef.getAfterScriptValueList()
if script_value_list:
kwargs = form_kw
sci = StateChangeInfo(
document, self, former_status, tdef, old_sdef, new_sdef, kwargs)
for script_id in script_id_list:
script = self._getOb(script_id)
for script in script_value_list:
# Script can be either script or workflow method
if script_id in old_sdef.getDestinationIdList() and \
self._getOb(script_id).getTriggerType() == TRIGGER_WORKFLOW_METHOD:
getattr(document, convertToMixedCase(self._getOb(script_id).getReference()))()
if script in old_sdef.getDestinationValueList() and \
self._getOb(script.id).getTriggerType() == TRIGGER_WORKFLOW_METHOD:
getattr(document, convertToMixedCase(self._getOb(script.id).getReference()))()
else:
# Pass lots of info to the script in a single parameter.
if script.getPortalType() == 'Workflow Script':
......
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