[Erp5-report] r24579 - /erp5/trunk/products/CMFActivity/ActivityBuffer.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Nov 13 12:06:33 CET 2008


Author: vincent
Date: Thu Nov 13 12:06:26 2008
New Revision: 24579

URL: http://svn.erp5.org?rev=24579&view=rev
Log:
Do not call _beginAndHook if we are already registered to transaction manager.
This fixes a bug introduced by recent possibility to call interaction workflow methods in beforeCommitHooks.
  Example scenario of this bug:
    - create an activity
    - trigger an interaction workflow action set to happen before commit, and which creates an activity
    - commit transaction
  In beforeCommitHooks:
   - activity will get pushed to its queue
   - interaction will trigger, creating an activity, causing ActivityBuffer to register itself again.
   - both activities will get pushed to their queue (both the already-pushed one and the new one, since ActivityBuffer does its cleanup only at transaction commit).
  So we get 3 activities, where 2 were expected, and those numbers get worse very quickly (!n behaviour, n being the number of registered interactions).

Modified:
    erp5/trunk/products/CMFActivity/ActivityBuffer.py

Modified: erp5/trunk/products/CMFActivity/ActivityBuffer.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/ActivityBuffer.py?rev=24579&r1=24578&r2=24579&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/ActivityBuffer.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/ActivityBuffer.py [utf8] Thu Nov 13 12:06:26 2008
@@ -69,8 +69,9 @@
     return buffer.uid_set_dict.setdefault(activity, set())
 
   def _register(self, activity_tool):
-    self._beginAndHook(activity_tool)
-    TM._register(self)
+    if not self._registered:
+      self._beginAndHook(activity_tool)
+      TM._register(self)
 
   # Keeps a list of messages to add and remove
   # at end of transaction




More information about the Erp5-report mailing list