Commit 6ea012aa authored by iv's avatar iv

ERP5Workflow: raise if script_id is not correct

parent 195aab30
......@@ -586,6 +586,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if tdef is None:
new_sdef = self.getSourceValue()
new_state = new_sdef.getReference()
if not new_sdef:
# Do nothing if there is no initial state. We may want to create
# workflows with no state at all, only for worklists.
......@@ -607,20 +608,19 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
sci = StateChangeInfo(
document, self, former_status, tdef, old_sdef, new_sdef, kwargs)
for script_id in script_id_list:
script = self._getOb(script_id, None)
if script:
# 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
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
# update variables
state_values = None
......@@ -696,14 +696,14 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
self.updateRoleMappingsFor(document)
# Execute the "after" script.
if tdef is not None and tdef.getAfterScriptIdList():
if tdef is not None:
script_id_list = tdef.getAfterScriptIdList()
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, None)
if script:
if script_id_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)
# Script can be either script or workflow method
if script_id in old_sdef.getDestinationIdList() and \
self._getOb(script_id).getTriggerType() == TRIGGER_WORKFLOW_METHOD:
......
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