Commit dffe25c6 authored by Vincent Pelletier's avatar Vincent Pelletier

Factorize getSecurityUidList and getSecurityQuery without dropping compatibility.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15440 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4cb6b073
......@@ -469,7 +469,11 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
"""
allowedRolesAndUsers, role_column_dict = self.getAllowedRolesAndUsers(**kw)
catalog = self.getSQLCatalog()
method = getattr(catalog, catalog.sql_search_security)
method = getattr(catalog, catalog.sql_search_security, None)
if method is None:
raise DeprecationWarning, "The usage of allowedRolesAndUsers is "\
"deprecated. Please update your catalog "\
"business template."
allowedRolesAndUsers = ["'%s'" % (role, ) for role in allowedRolesAndUsers]
security_uid_list = [x.uid for x in method(security_roles_list = allowedRolesAndUsers)]
return security_uid_list, role_column_dict
......@@ -480,19 +484,13 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
Build a query based on allowed roles or on a list of security_uid
values. The query takes into account the fact that some roles are
catalogued with columns.
TODO: use getSecurityUidList and drop compatibility with old
security system.
"""
allowedRolesAndUsers, role_column_dict = self.getAllowedRolesAndUsers(**kw)
catalog = self.getSQLCatalog()
method = getattr(catalog, catalog.sql_search_security, '')
original_query = query
if method in ('', None):
# XXX old way, should not be used anylonger
warnings.warn("The usage of allowedRolesAndUsers is deprecated.\n"
"Please update your business template erp5_mysql_innodb.",
DeprecationWarning)
try:
security_uid_list, role_column_dict = self.getSecurityUidListAndRoleColumnDict(**kw)
except DeprecationWarning, message:
warnings.warn(message, DeprecationWarning)
allowedRolesAndUsers, role_column_dict = self.getAllowedRolesAndUsers(**kw)
if role_column_dict:
query_list = []
for key, value in role_column_dict.items():
......@@ -506,8 +504,6 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
else:
query = Query(allowedRolesAndUsers=allowedRolesAndUsers)
else:
allowedRolesAndUsers = ["'%s'" % (role, ) for role in allowedRolesAndUsers]
security_uid_list = [x.uid for x in method(security_roles_list = allowedRolesAndUsers)]
if role_column_dict:
query_list = []
for key, value in role_column_dict.items():
......
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