Commit 33070d92 authored by Yusei Tahara's avatar Yusei Tahara

Changed reindex timing and its priority to low. Now reindex after to update all role mappings.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15383 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 28672714
......@@ -423,7 +423,8 @@ class ERP5TypeInformation( FactoryTypeInformation,
return factory_method(portal, id).propertyMap()
security.declarePrivate('updateLocalRolesOnSecurityGroups')
def updateLocalRolesOnSecurityGroups(self, ob, user_name = None):
def updateLocalRolesOnSecurityGroups(self, ob, user_name=None,
reindex=True):
"""
Assign Local Roles to Groups on object 'ob', based on Portal Type Role
Definitions and "ERP5 Role Definition" objects contained inside 'ob'.
......@@ -605,7 +606,8 @@ class ERP5TypeInformation( FactoryTypeInformation,
ob.manage_addLocalGroupRoles(group, role_list)
ob.manage_addLocalRoles(group, role_list)
# Make sure that the object is reindexed
ob.reindexObjectSecurity()
if reindex:
ob.reindexObjectSecurity()
# XXX compat. alias
security.declareProtected(Permissions.ModifyPortalContent,
......
......@@ -260,6 +260,8 @@ class RoleProviderBase:
"""
portal_catalog = self.portal_catalog
update_role_tag = "%s.%s" % (self.__class__.__name__, "updateRoleMapping")
object_list = portal_catalog(portal_type = self.id, limit=None)
# We need to use activities in order to make sure it will
# work for an important number of objects
......@@ -268,9 +270,17 @@ class RoleProviderBase:
object_path_list = [x.path for x in object_list]
for i in xrange(0, object_list_len, 100):
current_path_list = object_path_list[i:i+100]
portal_activities.activate(activity='SQLQueue')\
.callMethodOnObjectList(current_path_list,
'updateLocalRolesOnSecurityGroups')
portal_activities.activate(activity='SQLQueue',
priority=6,
tag=update_role_tag)\
.callMethodOnObjectList(current_path_list,
'updateLocalRolesOnSecurityGroups',
reindex=False)
portal_activities.activate(activity='SQLQueue',
priority=6,
after_tag=update_role_tag)\
.callMethodOnObjectList(current_path_list,
'reindexObjectSecurity')
if REQUEST is not None:
return self.manage_editRolesForm(REQUEST,
......
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