Commit ed0e9ffb authored by Yoshinori Okuji's avatar Yoshinori Okuji

Rename object to ob, because object is a builtin name.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8819 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 40be2558
...@@ -266,7 +266,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -266,7 +266,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
security.declareProtected(ERP5Permissions.ModifyPortalContent, security.declareProtected(ERP5Permissions.ModifyPortalContent,
'assignRoleToSecurityGroup') 'assignRoleToSecurityGroup')
def assignRoleToSecurityGroup(self, object, user_name = None): def assignRoleToSecurityGroup(self, ob, user_name = None):
""" """
Assign Local Roles to Groups on object, based on Portal Type Assign Local Roles to Groups on object, based on Portal Type
Role Definitions Role Definitions
...@@ -276,7 +276,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -276,7 +276,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
if user_name is None: if user_name is None:
# First try to guess from the owner # First try to guess from the owner
try: try:
user_name = object.getOwnerInfo()['id'] user_name = ob.getOwnerInfo()['id']
except AttributeError: except AttributeError:
pass pass
if user_name is None: if user_name is None:
...@@ -291,15 +291,15 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -291,15 +291,15 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
'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(ob=ob) # kw provided in order to take any appropriate action
#LOG('ERP5TypeInformation', 0, 'role_mapping = %r, object = %r' % (role_mapping, object)) #LOG('ERP5TypeInformation', 0, 'role_mapping = %r, object = %r' % (role_mapping, object))
# Create an empty local Role Definition dict # Create an empty local Role Definition dict
role_category_list_dict = {} role_category_list_dict = {}
# Fill it with explicit local roles defined as subobjects of current object # Fill it with explicit local roles defined as subobjects of current object
if getattr(aq_base(object), 'isPrincipiaFolderish', 0): if getattr(aq_base(ob), 'isPrincipiaFolderish', 0):
for roledef in object.objectValues(spec = 'ERP5 Role Definition'): for roledef in ob.objectValues(spec = 'ERP5 Role Definition'):
role_category_list_dict.setdefault(roledef.getRoleName(), []).append( role_category_list_dict.setdefault(roledef.getRoleName(), []).append(
{ {
'category_order' : ['agent'], 'category_order' : ['agent'],
...@@ -325,10 +325,10 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -325,10 +325,10 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
# get the script and apply it if dynamic_base_category_list is not empty # get the script and apply it if dynamic_base_category_list is not empty
if len(dynamic_base_category_list) > 0: if len(dynamic_base_category_list) > 0:
base_category_script_id = definition['base_category_script'] base_category_script_id = definition['base_category_script']
base_category_script = getattr(object, base_category_script_id, None) base_category_script = getattr(ob, base_category_script_id, None)
if base_category_script is not None: if base_category_script is not None:
# call the script, which should return either a dict or a list of dicts # call the script, which should return either a dict or a list of dicts
category_result = base_category_script(dynamic_base_category_list, user_name, object, object.getPortalType()) category_result = base_category_script(dynamic_base_category_list, user_name, ob, ob.getPortalType())
#LOG('ERP5TypeInformation', 0, 'category_result = %r' % (category_result,)) #LOG('ERP5TypeInformation', 0, 'category_result = %r' % (category_result,))
# 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
...@@ -356,7 +356,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -356,7 +356,7 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
# Generate security group ids from category_value_dicts # Generate security group ids from category_value_dicts
role_group_id_dict = {} role_group_id_dict = {}
group_id_generator = getattr(object, ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT, None) group_id_generator = getattr(ob, ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT, None)
if group_id_generator is None: if group_id_generator is None:
raise RuntimeError, '%s script was not found' % ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT raise RuntimeError, '%s script was not found' % ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT
for role, value_list in role_category_list_dict.items(): for role, value_list in role_category_list_dict.items():
...@@ -384,8 +384,8 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -384,8 +384,8 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
# Update role assignments to groups # 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 = ob.get_local_roles()
object.manage_delLocalRoles([x[0] for x in old_group_list]) ob.manage_delLocalRoles([x[0] for x in old_group_list])
# Save the owner # Save the owner
for group, role_list in old_group_list: for group, role_list in old_group_list:
if 'Owner' in role_list: if 'Owner' in role_list:
...@@ -395,13 +395,13 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -395,13 +395,13 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
group_id_role_dict[group].append('Owner') group_id_role_dict[group].append('Owner')
# 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) ob.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 = ob.get_local_group_roles()
# We duplicate role settings to mimic PAS # We duplicate role settings to mimic PAS
object.manage_delLocalGroupRoles([x[0] for x in old_group_list]) ob.manage_delLocalGroupRoles([x[0] for x in old_group_list])
object.manage_delLocalRoles([x[0] for x in old_group_list]) ob.manage_delLocalRoles([x[0] for x in old_group_list])
# Save the owner # Save the owner
for group, role_list in old_group_list: for group, role_list in old_group_list:
if 'Owner' in role_list: if 'Owner' in role_list:
...@@ -412,20 +412,25 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -412,20 +412,25 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
# 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():
# We duplicate role settings to mimic PAS # We duplicate role settings to mimic PAS
object.manage_addLocalGroupRoles(group, role_list) ob.manage_addLocalGroupRoles(group, role_list)
object.manage_addLocalRoles(group, role_list) ob.manage_addLocalRoles(group, role_list)
security.declarePublic('getFilteredRoleListFor') security.declarePublic('getFilteredRoleListFor')
def getFilteredRoleListFor(self, object=None, **kw): def getFilteredRoleListFor(self, ob=None, **kw):
""" """
Return a mapping containing of all roles applicable to the Return a mapping containing of all roles applicable to the
object against user. object against user.
""" """
# This is only for backward-compatibility. The keyword parameter
# took object instead of ob in the old implementation.
if ob is None:
ob = kw.get('object')
portal = self.portal_url.getPortalObject() portal = self.portal_url.getPortalObject()
if object is None: if ob is None:
folder = portal folder = portal
else: else:
folder = aq_parent(object) folder = aq_parent(ob)
# Search up the containment hierarchy until we find an # Search up the containment hierarchy until we find an
# object that claims it's a folder. # object that claims it's a folder.
while folder is not None: while folder is not None:
...@@ -435,10 +440,10 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -435,10 +440,10 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
else: else:
folder = aq_parent(folder) folder = aq_parent(folder)
ec = createExprContext(folder, portal, object) ec = createExprContext(folder, portal, ob)
roles = [] roles = []
append = roles.append append = roles.append
info = ori(self, folder, object) info = ori(self, folder, ob)
# Include actions from self # Include actions from self
self._filterRoleList(append,self,info,ec) self._filterRoleList(append,self,info,ec)
...@@ -458,9 +463,9 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation ...@@ -458,9 +463,9 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation
# #
# Helper methods # Helper methods
# #
def _filterRoleList(self,append,object,info,ec): def _filterRoleList(self, append, ob, info, ec):
r = object.getRoleList(info) r = ob.getRoleList(info)
if r and type(r[0]) is not type({}): if r and not isinstance(r[0], dict):
for ri in r: for ri in r:
if ri.testCondition(ec): if ri.testCondition(ec):
append(ri.getRole(ec)) append(ri.getRole(ec))
......
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