[Erp5-report] r42281 jm - /erp5/trunk/products/ERP5/InteractionWorkflow.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Jan 12 19:09:11 CET 2011


Author: jm
Date: Wed Jan 12 19:09:11 2011
New Revision: 42281

URL: http://svn.erp5.org?rev=42281&view=rev
Log:
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.

Modified:
    erp5/trunk/products/ERP5/InteractionWorkflow.py

Modified: erp5/trunk/products/ERP5/InteractionWorkflow.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/InteractionWorkflow.py?rev=42281&r1=42280&r2=42281&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/InteractionWorkflow.py [utf8] (original)
+++ erp5/trunk/products/ERP5/InteractionWorkflow.py [utf8] Wed Jan 12 19:09:11 2011
@@ -303,8 +303,9 @@ class InteractionWorkflowDefinition (DCW
 
               # 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 (DCW
                     .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]



More information about the Erp5-report mailing list