Commit 112770ee authored by Alexandre Boeglin's avatar Alexandre Boeglin

Allows to use same script multiple times with different categories.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5533 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2c0038eb
...@@ -69,7 +69,7 @@ class ERP5GroupManager(BasePlugin): ...@@ -69,7 +69,7 @@ class ERP5GroupManager(BasePlugin):
security_category_dict = {} # key is the base_category_list, security_category_dict = {} # key is the base_category_list,
# value is the list of fetched categories # value is the list of fetched categories
security_group_list = [] security_group_list = []
security_definition_dict = {} security_definition_list = ()
# because we aren't logged in, we have to create our own # because we aren't logged in, we have to create our own
# SecurityManager to be able to access the Catalog # SecurityManager to be able to access the Catalog
...@@ -79,24 +79,27 @@ class ERP5GroupManager(BasePlugin): ...@@ -79,24 +79,27 @@ class ERP5GroupManager(BasePlugin):
newSecurityManager(self, self.getPortalObject().getOwner()) newSecurityManager(self, self.getPortalObject().getOwner())
# To get the complete list of groups, we try to call the # To get the complete list of groups, we try to call the
# ERP5Type_getSecurityCategoryMapping which should return a dict # ERP5Type_getSecurityCategoryMapping which should return a list
# like : { # of lists of two elements (script, base_category_list) like :
# 'script_1':['base_category_1', 'base_category_2', ...], # (
# 'script_2':['base_category_1', 'base_category_3', ...]} # ('script_1', ['base_category_1', 'base_category_2', ...]),
# ('script_2', ['base_category_1', 'base_category_3', ...])
# )
# #
# else, if the script does not exist, falls back to : # else, if the script does not exist, falls back to a list containng
# { 'ERP5Type_getSecurityCategoryFromAssignment': # only one list :
# self.getPortalAssignmentBaseCategoryList()} # (('ERP5Type_getSecurityCategoryFromAssignment',
# self.getPortalAssignmentBaseCategoryList() ),)
mapping_method = getattr(self, mapping_method = getattr(self,
'ERP5Type_getSecurityCategoryMapping', None) 'ERP5Type_getSecurityCategoryMapping', None)
if mapping_method is None: if mapping_method is None:
security_definition_dict = { security_definition_list = ((
'ERP5Type_getSecurityCategoryFromAssignment': 'ERP5Type_getSecurityCategoryFromAssignment',
self.getPortalAssignmentBaseCategoryList() self.getPortalAssignmentBaseCategoryList()
} ),)
else: else:
security_definition_dict = mapping_method() security_definition_list = mapping_method()
# get the person from its reference # get the person from its reference
catalog_result = self.portal_catalog( catalog_result = self.portal_catalog(
...@@ -113,8 +116,8 @@ class ERP5GroupManager(BasePlugin): ...@@ -113,8 +116,8 @@ class ERP5GroupManager(BasePlugin):
person_id = person_object.getId() person_id = person_object.getId()
# Fetch category values from defined scripts # Fetch category values from defined scripts
for method_name, base_category_list in \ for (method_name, base_category_list) in \
security_definition_dict.items(): security_definition_list:
pickled_category_list = dumps(base_category_list) pickled_category_list = dumps(base_category_list)
method = getattr(self, method_name) method = getattr(self, method_name)
if not security_category_dict.has_key(pickled_category_list): if not security_category_dict.has_key(pickled_category_list):
......
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