From 9b56f836a89935a120b967045b00373a4cd9d464 Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Wed, 10 Mar 2010 19:43:54 +0000 Subject: [PATCH] BusinessTemplate: fix installation of roles ZODBRoleManager.listRoleIds() returns an iterator on existing roles. We must get a copy of the list before adding/removing roles. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33596 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/BusinessTemplate.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py index 6a2e94251d..161694a073 100644 --- a/product/ERP5/Document/BusinessTemplate.py +++ b/product/ERP5/Document/BusinessTemplate.py @@ -3261,24 +3261,17 @@ class RoleTemplateItem(BaseTemplateItem): p = context.getPortalObject() # get roles if context.getTemplateFormatVersion() == 1: - role_list = self._objects.keys() + role_set = set(self._objects) else: - role_list = self._archive.keys() + role_set = set(self._archive) # set roles in PAS if p.acl_users.meta_type == 'Pluggable Auth Service': role_manager_list = p.acl_users.objectValues('ZODB Role Manager') for role_manager in role_manager_list: - existing_role_list = role_manager.listRoleIds() - for role in role_list: - if role not in existing_role_list: - role_manager.addRole(role) + for role in role_set.difference(role_manager.listRoleIds()): + role_manager.addRole(role) # set roles on portal - roles = {} - for role in p.__ac_roles__: - roles[role] = 1 - for role in role_list: - roles[role] = 1 - p.__ac_roles__ = tuple(roles.keys()) + p.__ac_roles__ = tuple(role_set.union(p.__ac_roles__)) def _importFile(self, file_name, file): if not file_name.endswith('.xml'): -- 2.30.9