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
iv
erp5
Commits
bea4e3d4
Commit
bea4e3d4
authored
Oct 11, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: PERF: fix list getters on category
parent
cc8868b7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
28 deletions
+64
-28
product/ERP5Workflow/Document/Interaction.py
product/ERP5Workflow/Document/Interaction.py
+26
-14
product/ERP5Workflow/Document/State.py
product/ERP5Workflow/Document/State.py
+10
-0
product/ERP5Workflow/Document/Transition.py
product/ERP5Workflow/Document/Transition.py
+28
-14
No files found.
product/ERP5Workflow/Document/Interaction.py
View file @
bea4e3d4
...
...
@@ -76,30 +76,42 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject,
PropertySheet
.
Guard
,
)
# following getters are redefined for performance improvements
# they use the categories paths directly and string operations
# instead of traversing from the portal to get the objects
# in order to have their id or value
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getBeforeCommitScriptIdList'
)
def
getBeforeCommitScriptIdList
(
self
):
"""
redefine this getter for performance improvements:
instead of , from the portal, getting the workflow
and taking its script or transition, and repeting this for
all 'before commit script', just get the parent once
and find the script names from the category paths
returns the list of before commit script ids
"""
return
[
path
.
split
(
'/'
)[
-
1
]
for
path
in
self
.
getBeforeCommitScriptList
()]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getBeforeCommitScriptValueList'
)
def
getBeforeCommitScriptValueList
(
self
):
"""
returns the list of before commit script values
"""
parent
=
self
.
getParentValue
()
return
[
parent
.
_getOb
(
path
.
split
(
'/'
)[
-
1
])
for
path
in
self
.
getBeforeCommitScript
List
()]
return
[
parent
.
_getOb
(
transition_id
)
for
transition_id
in
self
.
getBeforeCommitScriptId
List
()]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getActivateScriptIdList'
)
def
getActivateScriptIdList
(
self
):
"""
redefine this getter for performance improvements:
instead of , from the portal, getting the workflow
and taking its script or transition, and repeting this for
all 'activate script', just get the parent once
and find the script names from the category paths
returns the list of activate script ids
"""
return
[
path
.
split
(
'/'
)[
-
1
]
for
path
in
self
.
getActivateScriptList
()]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getActivateScriptValueList'
)
def
getActivateScriptValueList
(
self
):
"""
returns the list of activate script values
"""
parent
=
self
.
getParentValue
()
return
[
parent
.
_getOb
(
path
.
split
(
'/'
)[
-
1
])
for
path
in
self
.
getActivateScript
List
()]
return
[
parent
.
_getOb
(
transition_id
)
for
transition_id
in
self
.
getActivateScriptId
List
()]
\ No newline at end of file
product/ERP5Workflow/Document/State.py
View file @
bea4e3d4
...
...
@@ -99,6 +99,16 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
"""
return
[
path
.
split
(
'/'
)[
-
1
]
for
path
in
self
.
getDestinationList
()]
def
getDestinationValueList
(
self
):
"""
this getter is redefined to improve performance:
instead of getting all the transition objects from the destination list
to then use their ids, extract the information from the string
"""
parent
=
self
.
getParentValue
()
return
[
parent
.
_getOb
(
destination_id
)
for
destination_id
in
self
.
getDestinationIdList
()]
def
getTransitions
(
self
):
# return possible transition id list:
return
self
.
getDestinationIdList
()
...
...
product/ERP5Workflow/Document/Transition.py
View file @
bea4e3d4
...
...
@@ -78,28 +78,42 @@ class Transition(IdAsReferenceMixin("transition_", "prefix"), XMLObject,
PropertySheet
.
ActionInformation
,
)
# following getters are redefined for performance improvements
# they use the categories paths directly and string operations
# instead of traversing from the portal to get the objects
# in order to have their id or value
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getBeforeScriptIdList'
)
def
getBeforeScriptIdList
(
self
):
"""
redefine this getter for performance improvements:
instead of , from the portal, getting the workflow
and taking its script or transition, and repeting this for
all 'before script', just get the parent once
and find the script names from the category paths
returns the list of before script ids
"""
return
[
self
.
getParentValue
().
_getOb
(
path
.
split
(
'/'
)[
-
1
])
for
path
in
self
.
getBeforeScriptList
()]
return
[
path
.
split
(
'/'
)[
-
1
]
for
path
in
self
.
getBeforeScriptList
()]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getBeforeScriptValueList'
)
def
getBeforeScriptValueList
(
self
):
"""
returns the list of before script values
"""
parent
=
self
.
getParentValue
()
return
[
parent
.
_getOb
(
transition_id
)
for
transition_id
in
self
.
getBeforeScriptIdList
()]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getAfterScriptIdList'
)
def
getAfterScriptIdList
(
self
):
"""
redefine this getter for performance improvements:
instead of , from the portal, getting the workflow
and taking its script or transition, and repeting this for
all 'after script', just get the parent once
and find the script names from the category paths
returns the list of after script ids
"""
return
[
path
.
split
(
'/'
)[
-
1
]
for
path
in
self
.
getAfterScriptList
()]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getAfterScriptValueList'
)
def
getAfterScriptValueList
(
self
):
"""
returns the list of after script values
"""
return
[
self
.
getParentValue
().
_getOb
(
path
.
split
(
'/'
)[
-
1
])
for
path
in
self
.
getAfterScriptList
()]
parent
=
self
.
getParentValue
()
return
[
parent
.
_getOb
(
transition_id
)
for
transition_id
in
self
.
getAfterScriptIdList
()]
\ No newline at end of file
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