Commit f1b70f2c authored by Jean-Paul Smets's avatar Jean-Paul Smets

asSecurityGroupId scripts can now return either string or list

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12980 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 618cb1d1
...@@ -145,39 +145,27 @@ class ERP5GroupManager(BasePlugin): ...@@ -145,39 +145,27 @@ class ERP5GroupManager(BasePlugin):
# Get group names from category values # Get group names from category values
group_id_list_generator = getattr(self, group_id_list_generator = getattr(self,
'ERP5Type_asSecurityGroupIdList', None) 'ERP5Type_asSecurityGroupIdList', None)
if group_id_list_generator is not None: if group_id_list_generator is None:
for base_category_list, category_value_list in \ group_id_list_generator = getattr(self, 'ERP5Type_asSecurityGroupId')
security_category_dict.items(): generator_name = "ERP5Type_asSecurityGroupId"
for category_dict in category_value_list:
try:
security_group_list.extend(
group_id_list_generator(category_order=base_category_list,
**category_dict)
)
except ConflictError:
raise
except:
LOG('ERP5GroupManager', WARNING,
'could not get security groups from '
'ERP5Type_asSecurityGroupIdList',
error = sys.exc_info())
else: else:
group_id_generator = getattr(self, 'ERP5Type_asSecurityGroupId') generator_name = 'ERP5Type_asSecurityGroupIdList'
for base_category_list, category_value_list in \ for base_category_list, category_value_list in \
security_category_dict.items(): security_category_dict.items():
for category_dict in category_value_list: for category_dict in category_value_list:
try: try:
security_group_list.append( group_id_list = group_id_list_generator(category_order=base_category_list,
group_id_generator(category_order=base_category_list, **category_dict)
**category_dict) LOG('group_id_list', 0, str(group_id_list))
) if isinstance(group_id_list, str): group_id_list = [group_id_list]
except ConflictError: security_group_list.extend(group_id_list)
raise except ConflictError:
except: raise
LOG('ERP5GroupManager', WARNING, except:
'could not get security groups from ' LOG('ERP5GroupManager', WARNING,
'ERP5Type_asSecurityGroupId', 'could not get security groups from %s' %
error = sys.exc_info()) generator_name,
error = sys.exc_info())
finally: finally:
setSecurityManager(sm) setSecurityManager(sm)
return tuple(security_group_list) return tuple(security_group_list)
...@@ -189,7 +177,6 @@ class ERP5GroupManager(BasePlugin): ...@@ -189,7 +177,6 @@ class ERP5GroupManager(BasePlugin):
path=self.getPhysicalPath()) path=self.getPhysicalPath())
classImplements( ERP5GroupManager classImplements( ERP5GroupManager
, IGroupsPlugin , IGroupsPlugin
) )
......
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