Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
erp5
Commits
2677d091
Commit
2677d091
authored
Apr 28, 2014
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Type.ERP5Type: Make updateRoleMapping work with 100k+ documents.
parent
e9c4256e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
+21
-27
product/ERP5Type/ERP5Type.py
product/ERP5Type/ERP5Type.py
+21
-27
No files found.
product/ERP5Type/ERP5Type.py
View file @
2677d091
...
...
@@ -76,7 +76,7 @@ class LocalRoleAssignorMixIn(object):
security
.
declarePrivate
(
'updateLocalRolesOnObject'
)
@
UnrestrictedMethod
def
updateLocalRolesOnDocument
(
self
,
ob
,
user_name
=
None
,
reindex
=
True
):
def
updateLocalRolesOnDocument
(
self
,
ob
,
user_name
=
None
,
reindex
=
True
,
activate_kw
=
()
):
"""
Assign Local Roles to Groups on object 'ob', based on Portal Type Role
Definitions and "ERP5 Role Definition" objects contained inside 'ob'.
...
...
@@ -132,7 +132,7 @@ class LocalRoleAssignorMixIn(object):
# XXX: Document modification detection assumes local roles are always
# part of ob and not separate persistent objects.
if
reindex
and
ob
.
_p_changed
:
ob
.
reindexObjectSecurity
()
ob
.
reindexObjectSecurity
(
activate_kw
=
dict
(
activate_kw
)
)
security
.
declarePrivate
(
'getFilteredRoleListFor'
)
def
getFilteredRoleListFor
(
self
,
ob
=
None
):
...
...
@@ -159,34 +159,28 @@ class LocalRoleAssignorMixIn(object):
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'updateRoleMapping'
)
def
updateRoleMapping
(
self
,
REQUEST
=
None
,
form_id
=
''
):
def
updateRoleMapping
(
self
,
REQUEST
=
None
,
form_id
=
''
,
priority
=
3
):
"""Update the local roles in existing objects.
XXX This should be implemented the same way as
ERP5Site_checkCatalogTable (cf erp5_administration).
"""
portal
=
self
.
getPortalObject
()
update_role_tag
=
self
.
__class__
.
__name__
+
".updateRoleMapping"
object_list
=
[
x
.
path
for
x
in
portal
.
portal_catalog
(
portal_type
=
self
.
id
,
limit
=
None
)]
object_list_len
=
len
(
object_list
)
# We need to use activities in order to make sure it will
# work for an important number of objects
activate
=
portal
.
portal_activities
.
activate
for
i
in
xrange
(
0
,
object_list_len
,
100
):
current_path_list
=
object_list
[
i
:
i
+
100
]
activate
(
activity
=
'SQLQueue'
,
priority
=
3
,
tag
=
update_role_tag
)
\
.
callMethodOnObjectList
(
current_path_list
,
'updateLocalRolesOnSecurityGroups'
,
reindex
=
False
)
activate
(
activity
=
'SQLQueue'
,
priority
=
3
,
after_tag
=
update_role_tag
)
\
.
callMethodOnObjectList
(
current_path_list
,
'reindexObjectSecurity'
)
self
.
getPortalObject
().
portal_catalog
.
searchAndActivate
(
'updateLocalRolesOnSecurityGroups'
,
method_kw
=
{
'activate_kw'
:
{
'priority'
:
priority
,
},
},
activate_kw
=
{
'priority'
:
priority
,
# XXX: Tag is just for easier manual lookup in activity tables.
'tag'
:
self
.
id
+
'.updateRoleMapping'
,
},
portal_type
=
self
.
id
,
)
if
REQUEST
is
not
None
:
message
=
'%d objects updated'
%
object_list_len
return
REQUEST
.
RESPONSE
.
redirect
(
'%s/%s?portal_status_message=%s'
%
(
self
.
absolute_url_path
(),
form_id
,
message
))
return
REQUEST
.
RESPONSE
.
redirect
(
self
.
absolute_url_path
()
+
'/'
+
form_id
+
'?portal_status_message=Updating%20local%20roles'
,
)
def
_importRole
(
self
,
role_property_dict
):
"""Import a role from a BT or from an old portal type"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment