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): ...@@ -469,7 +469,11 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
""" """
allowedRolesAndUsers, role_column_dict = self.getAllowedRolesAndUsers(**kw) allowedRolesAndUsers, role_column_dict = self.getAllowedRolesAndUsers(**kw)
catalog = self.getSQLCatalog() 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] allowedRolesAndUsers = ["'%s'" % (role, ) for role in allowedRolesAndUsers]
security_uid_list = [x.uid for x in method(security_roles_list = allowedRolesAndUsers)] security_uid_list = [x.uid for x in method(security_roles_list = allowedRolesAndUsers)]
return security_uid_list, role_column_dict return security_uid_list, role_column_dict
...@@ -480,19 +484,13 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -480,19 +484,13 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
Build a query based on allowed roles or on a list of security_uid 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 values. The query takes into account the fact that some roles are
catalogued with columns. 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 original_query = query
if method in ('', None): try:
# XXX old way, should not be used anylonger security_uid_list, role_column_dict = self.getSecurityUidListAndRoleColumnDict(**kw)
warnings.warn("The usage of allowedRolesAndUsers is deprecated.\n" except DeprecationWarning, message:
"Please update your business template erp5_mysql_innodb.", warnings.warn(message, DeprecationWarning)
DeprecationWarning) allowedRolesAndUsers, role_column_dict = self.getAllowedRolesAndUsers(**kw)
if role_column_dict: if role_column_dict:
query_list = [] query_list = []
for key, value in role_column_dict.items(): for key, value in role_column_dict.items():
...@@ -506,8 +504,6 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -506,8 +504,6 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
else: else:
query = Query(allowedRolesAndUsers=allowedRolesAndUsers) query = Query(allowedRolesAndUsers=allowedRolesAndUsers)
else: 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: if role_column_dict:
query_list = [] query_list = []
for key, value in role_column_dict.items(): 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