Commit c73fb018 authored by Julien Muchembled's avatar Julien Muchembled

InteractionWorkflow: fix before commit script for temp objects

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42285 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e3eff50e
...@@ -22,6 +22,7 @@ from Products.ERP5Type import Globals ...@@ -22,6 +22,7 @@ from Products.ERP5Type import Globals
import App import App
from types import StringTypes from types import StringTypes
from AccessControl import getSecurityManager, ClassSecurityInfo from AccessControl import getSecurityManager, ClassSecurityInfo
from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
from Products.DCWorkflow.Transitions import TRIGGER_WORKFLOW_METHOD from Products.DCWorkflow.Transitions import TRIGGER_WORKFLOW_METHOD
...@@ -303,9 +304,8 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject): ...@@ -303,9 +304,8 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
# Execute Before Commit # Execute Before Commit
for script_name in tdef.before_commit_script_name: for script_name in tdef.before_commit_script_name:
del sci.object
transaction.get().addBeforeCommitHook(self._before_commit, transaction.get().addBeforeCommitHook(self._before_commit,
(sci, ob.getPhysicalPath(), script_name)) (sci, script_name))
# Execute "activity" scripts # Execute "activity" scripts
for script_name in tdef.activate_script_name: for script_name in tdef.activate_script_name:
...@@ -313,11 +313,13 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject): ...@@ -313,11 +313,13 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
.activeScript(script_name, ob.getRelativeUrl(), .activeScript(script_name, ob.getRelativeUrl(),
status, tdef.id) status, tdef.id)
def _before_commit(self, sci, path, script_name): def _before_commit(self, sci, script_name):
try: # check the object still exists before calling the script
sci.object = self.unrestrictedTraverse(path) ob = sci.object
except KeyError: while ob.isTempObject():
return ob = ob.getParentValue()
if aq_base(self.unrestrictedTraverse(ob.getPhysicalPath(), None)) is \
aq_base(ob):
self.scripts[script_name](sci) self.scripts[script_name](sci)
security.declarePrivate('activeScript') security.declarePrivate('activeScript')
......
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