Commit 3062d0ad authored by Vincent Pelletier's avatar Vincent Pelletier

Add a cache in getSecurityUidListAndRoleColumnDict.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15483 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fd1e4ec4
...@@ -38,6 +38,7 @@ from Globals import InitializeClass, DTMLFile, package_home ...@@ -38,6 +38,7 @@ from Globals import InitializeClass, DTMLFile, package_home
from Acquisition import aq_base, aq_inner, aq_parent from Acquisition import aq_base, aq_inner, aq_parent
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
from Products.CMFActivity.ActiveObject import ActiveObject from Products.CMFActivity.ActiveObject import ActiveObject
from Products.ERP5Type.Cache import CachingMethod
from AccessControl.PermissionRole import rolesForPermissionOn from AccessControl.PermissionRole import rolesForPermissionOn
...@@ -464,8 +465,6 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -464,8 +465,6 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
""" """
Return a list of security Uids and a dictionnary containing available Return a list of security Uids and a dictionnary containing available
role columns. role columns.
TODO: Add a cache.
""" """
allowedRolesAndUsers, role_column_dict = self.getAllowedRolesAndUsers(**kw) allowedRolesAndUsers, role_column_dict = self.getAllowedRolesAndUsers(**kw)
catalog = self.getSQLCatalog() catalog = self.getSQLCatalog()
...@@ -475,10 +474,16 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -475,10 +474,16 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
"deprecated. Please update your catalog "\ "deprecated. Please update your catalog "\
"business template." "business template."
if allowedRolesAndUsers: if allowedRolesAndUsers:
# XXX: What with this string transformation ?! Souldn't it be done in allowedRolesAndUsers.sort()
# dtml instead ? def _getSecurityUidList(allowedRolesAndUsers):
allowedRolesAndUsers = ["'%s'" % (role, ) for role in allowedRolesAndUsers] # XXX: What with this string transformation ?! Souldn't it be done in
security_uid_list = [x.uid for x in method(security_roles_list = allowedRolesAndUsers)] # dtml instead ?
allowedRolesAndUsers = ["'%s'" % (role, ) for role in allowedRolesAndUsers]
security_uid_list = [x.uid for x in method(security_roles_list = allowedRolesAndUsers)]
_getSecurityUidList = CachingMethod(_getSecurityUidList,
id='_getSecurityUidList',
cache_factory='erp5_ui_short')
security_uid_list = _getSecurityUidList(allowedRolesAndUsers)
else: else:
security_uid_list = [] security_uid_list = []
return security_uid_list, role_column_dict return security_uid_list, role_column_dict
......
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