[Erp5-report] r30349 - /erp5/trunk/products/ERP5Type/ERP5Type.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Nov 5 18:12:22 CET 2009


Author: jm
Date: Thu Nov  5 18:12:21 2009
New Revision: 30349

URL: http://svn.erp5.org?rev=30349&view=rev
Log:
When updating local roles, call createExpressionContext only if required

This makes 'updateLocalRolesOnDocument' 2.5 times faster (according to
hotshot) if there is no security defined.

Modified:
    erp5/trunk/products/ERP5Type/ERP5Type.py

Modified: erp5/trunk/products/ERP5Type/ERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ERP5Type.py?rev=30349&r1=30348&r2=30349&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ERP5Type.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/ERP5Type.py [utf8] Thu Nov  5 18:12:21 2009
@@ -102,8 +102,10 @@
     security.declarePrivate('getFilteredRoleListFor')
     def getFilteredRoleListFor(self, ob=None):
       """Return all role generators applicable to the object."""
-      ec = createExpressionContext(ob)
+      ec = None # createExpressionContext is slow so we call it only if needed
       for role in self.getRoleInformationList():
+        if ec is None:
+          ec = createExpressionContext(ob)
         if role.testCondition(ec):
           yield role
 




More information about the Erp5-report mailing list