From 19ff132f4573b023e69925ae0a431737b3b4e5d1 Mon Sep 17 00:00:00 2001
From: Nicolas Dumazet <nicolas.dumazet@nexedi.com>
Date: Sat, 5 Feb 2011 06:26:25 +0000
Subject: [PATCH] We left out workflow resets during our aq_reset to
 resetDynamicDocuments switch in r43009. This was a mistake: add it again and
 explain why it's required.

This fixes the last 2 failures of testBase


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43097 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/dynamic/portal_type_class.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Type/dynamic/portal_type_class.py b/product/ERP5Type/dynamic/portal_type_class.py
index e3f82ac5f3..405ffbc64d 100644
--- a/product/ERP5Type/dynamic/portal_type_class.py
+++ b/product/ERP5Type/dynamic/portal_type_class.py
@@ -37,7 +37,7 @@ from accessor_holder import _generateBaseAccessorHolder, _generatePreferenceTool
 
 
 from Products.ERP5Type.mixin.temporary import TemporaryDocumentMixin
-from Products.ERP5Type.Base import _aq_reset, Base
+from Products.ERP5Type.Base import Base, resetRegisteredWorkflowMethod
 from Products.ERP5Type.Globals import InitializeClass
 from Products.ERP5Type.Utils import setDefaultClassProperties
 from Products.ERP5Type import document_class_registry, mixin_class_registry
@@ -494,6 +494,13 @@ def synchronizeDynamicModules(context, force=False):
   finally:
     Base.aq_method_lock.release()
 
+  # It's okay for classes to keep references to old methods - maybe.
+  # but we absolutely positively need to clear the workflow chains
+  # stored in WorkflowMethod objects: our generation of workflow
+  # methods adds/registers/wraps existing methods, but does not
+  # remove old chains. Do it now.
+  resetRegisteredWorkflowMethod()
+
   # Some method generations are based on portal methods, and portal
   # methods cache results. So it is safer to invalidate the cache.
   cache_tool = getattr(context, 'portal_caches', None)
-- 
2.30.9