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,25 +597,27 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -597,25 +597,27 @@ 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:
kwargs = form_kw script_value_list = tdef.getBeforeScriptValueList()
sci = StateChangeInfo( if script_value_list:
document, self, former_status, tdef, old_sdef, new_sdef, kwargs) kwargs = form_kw
for script_id in script_id_list: sci = StateChangeInfo(document, self, former_status, tdef, old_sdef,
script = self._getOb(script_id) new_sdef, kwargs)
# Pass lots of info to the script in a single parameter. for script in script_value_list:
if script.getPortalType() != 'Workflow Script': # Pass lots of info to the script in a single parameter.
raise NotImplementedError ('Unsupported Script %s for state %s'%(script_id, old_sdef.getReference())) if script.getPortalType() != 'Workflow Script':
try: raise NotImplementedError ('Unsupported Script %s for state %s' %
script(sci) # May throw an exception. (script.id, old_sdef.getReference()))
except ValidationFailed, validation_exc: try:
before_script_success = 0 script(sci) # May throw an exception.
before_script_error_message = deepcopy(validation_exc.msg) except ValidationFailed, validation_exc:
validation_exc_traceback = sys.exc_traceback before_script_success = 0
except ObjectMoved, moved_exc: before_script_error_message = deepcopy(validation_exc.msg)
ob = moved_exc.getNewObject() validation_exc_traceback = sys.exc_traceback
# Re-raise after transition except ObjectMoved, moved_exc:
ob = moved_exc.getNewObject()
# Re-raise after transition
# update variables # update variables
state_values = None state_values = None
...@@ -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