Commit 9b56f836 authored by Julien Muchembled's avatar Julien Muchembled

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
parent 8edb78ab
...@@ -3261,24 +3261,17 @@ class RoleTemplateItem(BaseTemplateItem): ...@@ -3261,24 +3261,17 @@ class RoleTemplateItem(BaseTemplateItem):
p = context.getPortalObject() p = context.getPortalObject()
# get roles # get roles
if context.getTemplateFormatVersion() == 1: if context.getTemplateFormatVersion() == 1:
role_list = self._objects.keys() role_set = set(self._objects)
else: else:
role_list = self._archive.keys() role_set = set(self._archive)
# set roles in PAS # set roles in PAS
if p.acl_users.meta_type == 'Pluggable Auth Service': if p.acl_users.meta_type == 'Pluggable Auth Service':
role_manager_list = p.acl_users.objectValues('ZODB Role Manager') role_manager_list = p.acl_users.objectValues('ZODB Role Manager')
for role_manager in role_manager_list: for role_manager in role_manager_list:
existing_role_list = role_manager.listRoleIds() for role in role_set.difference(role_manager.listRoleIds()):
for role in role_list:
if role not in existing_role_list:
role_manager.addRole(role) role_manager.addRole(role)
# set roles on portal # set roles on portal
roles = {} p.__ac_roles__ = tuple(role_set.union(p.__ac_roles__))
for role in p.__ac_roles__:
roles[role] = 1
for role in role_list:
roles[role] = 1
p.__ac_roles__ = tuple(roles.keys())
def _importFile(self, file_name, file): def _importFile(self, file_name, file):
if not file_name.endswith('.xml'): if not file_name.endswith('.xml'):
......
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