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): ...@@ -586,6 +586,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if tdef is None: if tdef is None:
new_sdef = self.getSourceValue() new_sdef = self.getSourceValue()
new_state = new_sdef.getReference() new_state = new_sdef.getReference()
if not new_sdef: if not new_sdef:
# Do nothing if there is no initial state. We may want to create # Do nothing if there is no initial state. We may want to create
# workflows with no state at all, only for worklists. # workflows with no state at all, only for worklists.
...@@ -607,20 +608,19 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -607,20 +608,19 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
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_id in script_id_list:
script = self._getOb(script_id, None) script = self._getOb(script_id)
if script: # 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: before_script_success = 0
before_script_success = 0 before_script_error_message = deepcopy(validation_exc.msg)
before_script_error_message = deepcopy(validation_exc.msg) validation_exc_traceback = sys.exc_traceback
validation_exc_traceback = sys.exc_traceback except ObjectMoved, moved_exc:
except ObjectMoved, moved_exc: ob = moved_exc.getNewObject()
ob = moved_exc.getNewObject() # Re-raise after transition
# Re-raise after transition
# update variables # update variables
state_values = None state_values = None
...@@ -696,14 +696,14 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -696,14 +696,14 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
self.updateRoleMappingsFor(document) self.updateRoleMappingsFor(document)
# Execute the "after" script. # Execute the "after" script.
if tdef is not None and tdef.getAfterScriptIdList(): if tdef is not None:
script_id_list = tdef.getAfterScriptIdList() script_id_list = tdef.getAfterScriptIdList()
kwargs = form_kw if script_id_list:
sci = StateChangeInfo( kwargs = form_kw
document, self, former_status, tdef, old_sdef, new_sdef, kwargs) sci = StateChangeInfo(
for script_id in script_id_list: document, self, former_status, tdef, old_sdef, new_sdef, kwargs)
script = self._getOb(script_id, None) for script_id in script_id_list:
if script: 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_id in old_sdef.getDestinationIdList() and \
self._getOb(script_id).getTriggerType() == TRIGGER_WORKFLOW_METHOD: 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