Commit 2b238468 authored by Julien Muchembled's avatar Julien Muchembled

Speed up 'ERP5TypeInformation.updateLocalRolesOnDocument'

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30331 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent de9a6009
...@@ -72,17 +72,15 @@ class LocalRoleAssignorMixIn(object): ...@@ -72,17 +72,15 @@ class LocalRoleAssignorMixIn(object):
group_id_role_dict = self.getLocalRolesFor(ob, user_name) group_id_role_dict = self.getLocalRolesFor(ob, user_name)
## Update role assignments to groups ## Update role assignments to groups
# Clean old group roles
old_group_list = ob.get_local_roles()
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 (ob.__ac_local_roles__ or {}).iteritems():
if 'Owner' in role_list: if 'Owner' in role_list:
group_id_role_dict.setdefault(group, set()).add('Owner') group_id_role_dict.setdefault(group, set()).add('Owner')
# Assign new roles # Assign new roles
ob.__ac_local_roles__ = ac_local_roles = {}
for group, role_list in group_id_role_dict.iteritems(): for group, role_list in group_id_role_dict.iteritems():
if role_list: if role_list:
ob.manage_addLocalRoles(group, role_list) ac_local_roles[group] = list(role_list)
## Make sure that the object is reindexed ## Make sure that the object is reindexed
if reindex: if reindex:
ob.reindexObjectSecurity() ob.reindexObjectSecurity()
......
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