Commit f82f2b97 authored by Alexandre Boeglin's avatar Alexandre Boeglin

continue is better than return if we depend on more than one script.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4298 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 38e8e38e
...@@ -113,7 +113,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ): ...@@ -113,7 +113,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
, 'mode':'w' , 'mode':'w'
, 'label':'Base Categories' , 'label':'Base Categories'
, 'select_variable':'getBaseCategoryList' , 'select_variable':'getBaseCategoryList'
}, },
)) ))
acquire_local_roles = True acquire_local_roles = True
...@@ -156,7 +156,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ): ...@@ -156,7 +156,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
""" """
Build a "bare" instance of the appropriate type in Build a "bare" instance of the appropriate type in
'container', using 'id' as its id. 'container', using 'id' as its id.
Call the init_script for the portal_type, unless the Call the init_script for the portal_type, unless the
keyword arg __bypass_init_script is set to True. keyword arg __bypass_init_script is set to True.
Returns the object. Returns the object.
""" """
...@@ -222,10 +222,10 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ): ...@@ -222,10 +222,10 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
user_name = getSecurityManager().getUser().getId() # We use id for roles in ERP5Security user_name = getSecurityManager().getUser().getId() # We use id for roles in ERP5Security
elif NuxUserGroups is not None: elif NuxUserGroups is not None:
user_name = getSecurityManager().getUser().getUserName() user_name = getSecurityManager().getUser().getUserName()
else: else:
raise RuntimeError, 'Product "NuxUserGroups" was not found on your setup. '\ raise RuntimeError, 'Product "NuxUserGroups" was not found on your setup. '\
'Please install it to benefit from group-based security' 'Please install it to benefit from group-based security'
# Retrieve applicable roles # Retrieve applicable roles
role_mapping = self.getFilteredRoleListFor(object=object) # kw provided in order to take any appropriate action role_mapping = self.getFilteredRoleListFor(object=object) # kw provided in order to take any appropriate action
role_category_list = {} role_category_list = {}
...@@ -256,7 +256,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ): ...@@ -256,7 +256,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
# If we decide in the script that we don't want to update the security for this object, # If we decide in the script that we don't want to update the security for this object,
# we can just have it return None instead of a dict or list of dicts # we can just have it return None instead of a dict or list of dicts
if category_result is None: if category_result is None:
return continue
if type(category_result) is type({}): if type(category_result) is type({}):
category_result = [category_result] category_result = [category_result]
else: else:
...@@ -288,25 +288,27 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ): ...@@ -288,25 +288,27 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
role_group_dict[group_id] = 1 role_group_dict[group_id] = 1
role_group_id_dict[role].extend(role_group_dict.keys()) role_group_id_dict[role].extend(role_group_dict.keys())
#Switch index from role to group id # Switch index from role to group id
group_id_role_dict = {} group_id_role_dict = {}
for role, group_list in role_group_id_dict.items(): for role, group_list in role_group_id_dict.items():
for group_id in group_list: for group_id in group_list:
if not group_id_role_dict.has_key(group_id): if not group_id_role_dict.has_key(group_id):
group_id_role_dict[group_id] = [] group_id_role_dict[group_id] = []
group_id_role_dict[group_id].append(role) group_id_role_dict[group_id].append(role)
# Update role assignments to groups
if ERP5UserManager is not None: # Default implementation if ERP5UserManager is not None: # Default implementation
#Clean old group roles # Clean old group roles
old_group_list = object.get_local_roles() old_group_list = object.get_local_roles()
object.manage_delLocalRoles([x[0] for x in old_group_list]) object.manage_delLocalRoles([x[0] for x in old_group_list])
#Assign new roles # Assign new roles
for group, role_list in group_id_role_dict.items(): for group, role_list in group_id_role_dict.items():
object.manage_addLocalRoles(group, role_list) object.manage_addLocalRoles(group, role_list)
else: # NuxUserGroups implementation else: # NuxUserGroups implementation
#Clean old group roles # Clean old group roles
old_group_list = object.get_local_group_roles() old_group_list = object.get_local_group_roles()
object.manage_delLocalGroupRoles([x[0] for x in old_group_list]) object.manage_delLocalGroupRoles([x[0] for x in old_group_list])
#Assign new roles # Assign new roles
for group, role_list in group_id_role_dict.items(): for group, role_list in group_id_role_dict.items():
object.manage_addLocalGroupRoles(group, role_list) object.manage_addLocalGroupRoles(group, role_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