Commit 3f13489d authored by Sebastien Robin's avatar Sebastien Robin

ERP5Security: make ERP5GroupManager more resistant in extreme cases

When accessing an ERP5 Site, we might have automatic migration of
tools. When this happens, we might not have yet access to scripts
like ERP5Type_asSecurityGroupId.

There was already try/except, so just move slightly more code
inside.
parent f19a3c76
......@@ -131,7 +131,6 @@ class ERP5GroupManager(BasePlugin):
# Fetch category values from defined scripts
for (method_name, base_category_list) in security_definition_list:
base_category_list = tuple(base_category_list)
method = getattr(self, method_name)
security_category_list = security_category_dict.setdefault(
base_category_list, [])
try:
......@@ -139,6 +138,7 @@ class ERP5GroupManager(BasePlugin):
# from here or from _updateLocalRolesOnSecurityGroups.
# Currently, passing portal_type='' (instead of 'Person')
# is the only way to make the difference.
method = getattr(self, method_name)
security_category_list.extend(
method(base_category_list, user_id, person_object, '')
)
......@@ -155,7 +155,7 @@ class ERP5GroupManager(BasePlugin):
group_id_list_generator = getattr(self, generator_name, None)
if group_id_list_generator is None:
generator_name = ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT
group_id_list_generator = getattr(self, generator_name)
group_id_list_generator = getattr(self, generator_name, None)
for base_category_list, category_value_list in \
security_category_dict.iteritems():
for category_dict in category_value_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