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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastien Robin
erp5
Commits
92cfba78
Commit
92cfba78
authored
Oct 11, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: PERF: improve getStatePermissionRolesDict and remove
a few useless methods
parent
4a3f3be4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
33 deletions
+12
-33
product/ERP5Workflow/Document/State.py
product/ERP5Workflow/Document/State.py
+0
-16
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+10
-9
product/ERP5Workflow/Tool/WorkflowTool.py
product/ERP5Workflow/Tool/WorkflowTool.py
+2
-8
No files found.
product/ERP5Workflow/Document/State.py
View file @
92cfba78
...
...
@@ -113,16 +113,6 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
# return possible transition id list:
return
self
.
getDestinationIdList
()
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getStatePermissionRolesDict'
)
def
getStatePermissionRolesDict
(
self
):
role_dict
=
getattr
(
self
,
'state_permission_roles'
,
None
)
if
role_dict
is
None
:
# PersistentMapping is required to have changes on the dict
# commited in the ZODB
self
.
state_permission_roles
=
role_dict
=
PersistentMapping
()
return
role_dict
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setStatePermissionRolesDict'
)
def
setStatePermissionRolesDict
(
self
,
permission_roles
):
...
...
@@ -141,12 +131,6 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
"""
self
.
state_permission_roles
[
permission
]
=
list
(
roles
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getDestinationReferenceList'
)
def
getDestinationReferenceList
(
self
):
return
[
transition
.
getReference
()
for
transition
in
self
.
getDestinationValueList
()]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getAvailableTypeList'
)
def
getAvailableTypeList
(
self
):
...
...
product/ERP5Workflow/Document/Workflow.py
View file @
92cfba78
...
...
@@ -227,15 +227,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
state
=
self
.
_getWorkflowStateOf
(
document
,
id_only
=
False
)
if
state
is
not
None
:
state_permission_list
=
state
.
getAcquirePermissionList
()
for
permission
,
role_list
in
state
.
getStatePermissionRolesDict
().
items
():
# tuple means "don't acquire" in zope internal security and list
# is used when acquisition should be done
if
permission
in
state_permission_list
:
role_list
=
list
(
role_list
)
else
:
role_list
=
tuple
(
role_list
)
if
modifyRolesForPermission
(
document
,
permission
,
role_list
):
changed
=
True
if
hasattr
(
state
,
'getStatePermissionRolesDict'
):
for
permission
,
role_list
in
state
.
getStatePermissionRolesDict
().
items
():
# tuple means "don't acquire" in zope internal security and list
# is used when acquisition should be done
if
permission
in
state_permission_list
:
role_list
=
list
(
role_list
)
else
:
role_list
=
tuple
(
role_list
)
if
modifyRolesForPermission
(
document
,
permission
,
role_list
):
changed
=
True
return
changed
# This method allows to update all objects using one workflow, for example
...
...
product/ERP5Workflow/Tool/WorkflowTool.py
View file @
92cfba78
...
...
@@ -255,15 +255,9 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
return
wfh
.
get
(
wf_id
,
None
)
return
()
def
decodeWorkflowUid
(
self
,
uid
):
return
cPickle
.
loads
(
b64decode
(
uid
))
def
encodeWorkflowUid
(
self
,
id
):
def
_encodeWorkflowUid
(
self
,
id
):
return
b64encode
(
cPickle
.
dumps
(
id
))
def
getObjectFromPath
(
self
,
path
):
return
self
.
unrestrictedTraverse
(
path
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getWorkflowTempObjectList'
)
def
getWorkflowTempObjectList
(
self
,
temp_obj
=
1
):
...
...
@@ -308,7 +302,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
new_id
=
dc_workflow
.
id
else
:
new_id
=
'converting_'
+
dc_workflow
.
id
uid
=
self
.
encodeWorkflowUid
(
new_id
)
uid
=
self
.
_
encodeWorkflowUid
(
new_id
)
portal_type
=
(
'Workflow'
if
workflow_type_id
==
'DCWorkflowDefinition'
else
'Interaction Workflow'
)
workflow
=
self
.
newContent
(
id
=
new_id
,
temp_object
=
is_temporary
,
portal_type
=
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