From 81a35e3da0806a6044acfe4f8326724083f1282d Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Thu, 13 Nov 2008 11:06:26 +0000 Subject: [PATCH] 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). git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24579 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/CMFActivity/ActivityBuffer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/product/CMFActivity/ActivityBuffer.py b/product/CMFActivity/ActivityBuffer.py index 6db45d369f..1f58ba6bee 100644 --- a/product/CMFActivity/ActivityBuffer.py +++ b/product/CMFActivity/ActivityBuffer.py @@ -69,8 +69,9 @@ class ActivityBuffer(TM): 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 -- 2.30.9