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):
# Execute the "before" script.
before_script_success = 1
if tdef is not None and tdef.getBeforeScriptIdList():
script_id_list = tdef.getBeforeScriptIdList()
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)
# 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()))
try:
script(sci) # May throw an exception.
except ValidationFailed, validation_exc:
before_script_success = 0
before_script_error_message = deepcopy(validation_exc.msg)
validation_exc_traceback = sys.exc_traceback
except ObjectMoved, moved_exc:
ob = moved_exc.getNewObject()
# Re-raise after transition
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 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()))
try:
script(sci) # May throw an exception.
except ValidationFailed, validation_exc:
before_script_success = 0
before_script_error_message = deepcopy(validation_exc.msg)
validation_exc_traceback = sys.exc_traceback
except ObjectMoved, moved_exc:
ob = moved_exc.getNewObject()
# Re-raise after transition
# update variables
state_values = None
......@@ -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