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
32d0382e
Commit
32d0382e
authored
Oct 17, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: PERF: avoid compilation of expression being done again and again
parent
9a61b162
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
18 deletions
+28
-18
product/ERP5Workflow/Document/InteractionWorkflow.py
product/ERP5Workflow/Document/InteractionWorkflow.py
+2
-2
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+5
-6
product/ERP5Workflow/Document/WorkflowVariable.py
product/ERP5Workflow/Document/WorkflowVariable.py
+11
-2
product/ERP5Workflow/Document/Worklist.py
product/ERP5Workflow/Document/Worklist.py
+5
-3
product/ERP5Workflow/Tool/WorkflowTool.py
product/ERP5Workflow/Tool/WorkflowTool.py
+5
-5
No files found.
product/ERP5Workflow/Document/InteractionWorkflow.py
View file @
32d0382e
...
...
@@ -147,7 +147,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
# Not set yet. Use a default.
elif
variable_expression
is
not
None
:
ec
=
createExprContext
(
StateChangeInfo
(
ob
,
self
,
status
))
value
=
Expression
(
variable_expression
)
(
ec
)
value
=
variable_expression
(
ec
)
else
:
value
=
vdef
.
getVariableValue
()
...
...
@@ -289,7 +289,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
else
:
variable_expression
=
vdef
.
getVariableExpression
()
if
variable_expression
is
not
None
:
expression
=
Expression
(
variable_expression
)
expression
=
variable_expression
else
:
value
=
vdef
.
getVariableValue
()
if
expression
is
not
None
:
...
...
product/ERP5Workflow/Document/Workflow.py
View file @
32d0382e
...
...
@@ -481,7 +481,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
# Not set yet. Use a default.
elif
variable_expression
is
not
None
:
ec
=
createExprContext
(
StateChangeInfo
(
ob
,
self
,
status
))
value
=
Expression
(
variable_expression
)
(
ec
)
value
=
variable_expression
(
ec
)
else
:
value
=
vdef
.
getVariableValue
()
...
...
@@ -715,7 +715,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
expr
=
variable_expression
else
:
value
=
vdef
.
getVariableValue
(
object
=
object
)
if
expr
not
in
(
None
,
''
):
if
expr
not
in
(
None
,
''
):
# Evaluate an expression.
if
econtext
is
None
:
# Lazily create the expression context.
...
...
@@ -725,7 +725,6 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
document
,
self
,
former_status
,
tdef
,
old_sdef
,
new_sdef
,
kwargs
)
econtext
=
createExprContext
(
sci
)
expr
=
Expression
(
expr
)
value
=
expr
(
econtext
)
status_dict
[
variable_reference
]
=
value
# Do not proceed in case of failure of before script
...
...
@@ -949,7 +948,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
for
tr_var
in
tr_var_list
:
reference
=
self
.
_getOb
(
tr_var
.
getCausalityId
()).
getReference
()
transition_variable
=
SubElement
(
transition_variables
,
property_id
,
attrib
=
dict
(
id
=
reference
,
type
=
'variable'
))
transition_variable
.
text
=
str
(
tr_var
.
getVariableExpression
())
transition_variable
.
text
=
str
(
tr_var
.
getVariableExpression
Text
())
else
:
property_value
=
tdef
.
getProperty
(
property_id
)
property_type
=
tdef
.
getPropertyType
(
property_id
)
...
...
@@ -1123,7 +1122,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
else
:
variable_expression
=
vdef
.
getVariableExpression
()
if
variable_expression
is
not
None
:
expr
=
Expression
(
variable_expression
)
expr
=
variable_expression
else
:
value
=
vdef
.
getVariableValue
()
if
expr
is
not
None
:
...
...
@@ -1183,7 +1182,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
elif
variable_expression
is
not
None
:
ec
=
createExprContext
(
StateChangeInfo
(
ob
,
self
,
status
))
# convert string to expression before execute it.
value
=
Expression
(
variable_expression
)
(
ec
)
value
=
variable_expression
(
ec
)
else
:
value
=
variable
.
getVariableValue
()
if
hasattr
(
self
,
'getSourceValue'
):
...
...
product/ERP5Workflow/Document/WorkflowVariable.py
View file @
32d0382e
...
...
@@ -35,7 +35,7 @@ from Products.ERP5Type.XMLObject import XMLObject
class
WorkflowVariable
(
IdAsReferenceMixin
(
"variable_"
,
"prefix"
),
XMLObject
):
"""
A ERP5 Variable.
A ERP5
Workflow
Variable.
"""
meta_type
=
'ERP5 Variable'
...
...
@@ -65,6 +65,15 @@ class WorkflowVariable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
PropertySheet
.
WorkflowVariable
,
)
def
_setVariableExpression
(
self
,
expression
):
if
isinstance
(
expression
,
Expression
):
self
.
variable_expression
=
Expression
(
expression
.
text
)
else
:
self
.
variable_expression
=
Expression
(
expression
)
def
getVariableExpressionText
(
self
):
return
getattr
(
self
.
variable_expression
,
'text'
,
''
)
def
getInfoGuard
(
self
):
if
self
.
getGuardRoleList
()
is
None
and
\
self
.
getGuardPermissionList
()
is
None
and
\
...
...
@@ -73,7 +82,7 @@ class WorkflowVariable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
self
.
info_guard
is
None
:
return
Guard
().
__of__
(
self
)
elif
self
.
info_guard
is
None
:
self
.
generateGuard
()
self
.
generate
Info
Guard
()
return
self
.
info_guard
def
generateInfoGuard
(
self
):
...
...
product/ERP5Workflow/Document/Worklist.py
View file @
32d0382e
...
...
@@ -177,10 +177,12 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject,
if
dynamic_variable
.
getVariableValue
():
matches
=
[
dynamic_variable
.
getVariableValue
()]
# Override initial value if expression set:
if
dynamic_variable
.
getVariableExpression
():
matches
=
Expression
(
dynamic_variable
.
getVariableExpression
())
dynamic_variable_expression_text
=
dynamic_variable
\
.
getVariableExpression
()
if
dynamic_variable_expression_text
:
matches
=
dynamic_variable_expression_text
if
matches
is
not
[]
and
matches
is
not
None
:
if
matches
not
in
([],
None
)
:
if
not
isinstance
(
matches
,
(
tuple
,
Expression
)):
# Old version, convert it.
matches
=
tuple
(
matches
)
...
...
product/ERP5Workflow/Tool/WorkflowTool.py
View file @
32d0382e
...
...
@@ -461,7 +461,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
worklist_variable_value
=
worklist
.
newContent
(
portal_type
=
'Worklist Variable'
,
reference
=
key
)
if
isinstance
(
values
,
Expression
):
worklist_variable_value
.
setVariableExpression
(
values
.
text
)
worklist_variable_value
.
setVariableExpression
(
values
)
else
:
worklist_variable_value
.
setVariableValue
(
values
[
0
])
#XXX(WORKFLOW): to be changed
...
...
@@ -537,9 +537,9 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# for a very specific case, action return the reference of transition
# in order to generation correct workflow history.
if
variable_id
==
'action'
:
variable
.
setVariableExpression
(
'transition/getReference|nothing'
)
variable
.
setVariableExpression
(
Expression
(
'transition/getReference|nothing'
)
)
else
:
variable
.
setVariableExpression
(
variable_definition
.
default_expr
.
text
)
variable
.
setVariableExpression
(
variable_definition
.
default_expr
)
if
variable_definition
.
info_guard
:
variable
.
info_guard
=
variable_definition
.
info_guard
variable
.
setGuardRoleList
(
variable_definition
.
info_guard
.
roles
)
...
...
@@ -565,7 +565,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
else
:
var_exprs
=
origin_tdef
.
var_exprs
for
key
in
var_exprs
:
tr_var
=
transition
.
newContent
(
portal_type
=
'Transition Variable'
,
temp_object
=
is_temporary
)
tr_var
.
setVariableExpression
(
var_exprs
[
key
]
.
text
)
tr_var
.
setVariableExpression
(
var_exprs
[
key
])
tr_var_path
=
getattr
(
workflow
,
'variable_'
+
key
).
getPath
()
tr_var_path
=
'/'
.
join
(
tr_var_path
.
split
(
'/'
)[
2
:])
new_category
.
append
(
tr_var_path
)
...
...
@@ -582,7 +582,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
else
:
var_exprs
=
origin_tdef
.
var_exprs
for
key
in
var_exprs
:
tr_var
=
interaction
.
newContent
(
portal_type
=
'Transition Variable'
,
temp_object
=
is_temporary
)
tr_var
.
setVariableExpression
(
var_exprs
[
key
]
.
text
)
tr_var
.
setVariableExpression
(
var_exprs
[
key
])
tr_var_path
=
getattr
(
workflow
,
'variable_'
+
key
).
getPath
()
tr_var_path
=
'/'
.
join
(
tr_var_path
.
split
(
'/'
)[
2
:])
new_category
.
append
(
tr_var_path
)
...
...
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