Commit a0b2c2b5 authored by Julien Muchembled's avatar Julien Muchembled

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.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30349 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f8bd8561
...@@ -102,8 +102,10 @@ class LocalRoleAssignorMixIn(object): ...@@ -102,8 +102,10 @@ class LocalRoleAssignorMixIn(object):
security.declarePrivate('getFilteredRoleListFor') security.declarePrivate('getFilteredRoleListFor')
def getFilteredRoleListFor(self, ob=None): def getFilteredRoleListFor(self, ob=None):
"""Return all role generators applicable to the object.""" """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(): for role in self.getRoleInformationList():
if ec is None:
ec = createExpressionContext(ob)
if role.testCondition(ec): if role.testCondition(ec):
yield role yield role
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment