Commit 53be0be5 authored by Julien Muchembled's avatar Julien Muchembled

InteractionWorkflow: check the object still exists when executing before commit

This fixes several unit tests (with not executable activities) where an object
is created and deleted in the same transaction, whereas an interaction
(ex: document_security_interaction_workflow) creates activities for this object
just before committing. The 'flush' happens earlier.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42281 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c242ccbc
......@@ -303,8 +303,9 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
# Execute Before Commit
for script_name in tdef.before_commit_script_name:
script = self.scripts[script_name]
transaction.get().addBeforeCommitHook(script, (sci,))
del sci.object
transaction.get().addBeforeCommitHook(self._before_commit,
(sci, ob.getPhysicalPath(), script_name))
# Execute "activity" scripts
for script_name in tdef.activate_script_name:
......@@ -312,6 +313,13 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
.activeScript(script_name, ob.getRelativeUrl(),
status, tdef.id)
def _before_commit(self, sci, path, script_name):
try:
sci.object = self.unrestrictedTraverse(path)
except KeyError:
return
self.scripts[script_name](sci)
security.declarePrivate('activeScript')
def activeScript(self, script_name, ob_url, status, tdef_id):
script = self.scripts[script_name]
......
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