[Erp5-report] r42785 nicolas.dumazet - /erp5/trunk/products/ERP5/Interactor/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jan 31 03:17:37 CET 2011


Author: nicolas.dumazet
Date: Mon Jan 31 03:17:37 2011
New Revision: 42785

URL: http://svn.erp5.org?rev=42785&view=rev
Log:
delay interaction so it happens once at end of transaction

This avoids resetting several times the dynamic methods,
and should mean faster BT installation

Modified:
    erp5/trunk/products/ERP5/Interactor/PortalTypeClassInteractor.py

Modified: erp5/trunk/products/ERP5/Interactor/PortalTypeClassInteractor.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Interactor/PortalTypeClassInteractor.py?rev=42785&r1=42784&r2=42785&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Interactor/PortalTypeClassInteractor.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Interactor/PortalTypeClassInteractor.py [utf8] Mon Jan 31 03:17:37 2011
@@ -28,11 +28,13 @@
 ##############################################################################
 
 from Products.ERP5Type.Interactor.Interactor import Interactor
+import transaction
+from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
 
 class PortalTypeClassInteractor(Interactor):
   """
     This interactor handles all the calls to resetDynamicDocuments
-    which must be trigered whenever some parts of ERP5 
+    which must be trigered whenever some parts of ERP5
     are modified and require to generate again accessors
     and dynamic properties.
   """
@@ -52,12 +54,20 @@ class PortalTypeClassInteractor(Interact
 
   def resetDynamic(self, method_call_object, *args, **kw):
     """
-    Call resetDynamicDocuments
+    Call resetDynamicDocuments at the end of the transaction
     """
     from Products.ERP5.ERP5Site import getSite
     # method_call_object might be an unwrapped DCWorflowDefinition method,
     # no even belonging to a container.
     portal = getSite()
     types_tool = getattr(portal, 'portal_types', None)
-    if types_tool is not None:
-      types_tool.resetDynamicDocuments()
+    if types_tool is None:
+      return
+
+    # XXX this could be a generic doOnceAtEndOfTransaction in
+    # Interactor baseclass
+    tv = getTransactionalVariable()
+    key = 'Interactor.PortalTypeClassInteractor.resetDynamic'
+    if key not in tv:
+      tv[key] = None
+      transaction.get().addBeforeCommitHook(types_tool.resetDynamicDocuments)



More information about the Erp5-report mailing list