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