Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_workflow
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenjie.zheng
erp5_workflow
Commits
3221daf3
Commit
3221daf3
authored
Nov 12, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workflow.py: deploy property accessors as many as possible.
parent
775bab2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
24 deletions
+26
-24
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+26
-24
No files found.
product/ERP5Workflow/Document/Workflow.py
View file @
3221daf3
...
...
@@ -166,7 +166,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
return
0
if
(
transition
in
sdef
.
getDestinationValueList
()
and
self
.
_checkTransitionGuard
(
transition
,
document
)
and
transition
.
trigger_type
==
TRIGGER_WORKFLOW_METHOD
transition
.
getTriggerType
()
==
TRIGGER_WORKFLOW_METHOD
):
return
1
return
0
...
...
@@ -184,7 +184,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if
action
in
sdef
.
getDestinationIdList
():
tdef
=
self
.
_getOb
(
action
,
None
)
if
(
tdef
is
not
None
and
tdef
.
trigger_type
==
TRIGGER_USER_ACTION
and
tdef
.
getTriggerType
()
==
TRIGGER_USER_ACTION
and
self
.
_checkTransitionGuard
(
tdef
,
document
,
**
kw
)):
return
1
return
0
...
...
@@ -212,7 +212,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
def
_findAutomaticTransition
(
self
,
document
,
sdef
):
tdef
=
None
for
t
in
sdef
.
getDestinationValueList
():
if
t
.
trigger_type
==
TRIGGER_AUTOMATIC
:
if
t
.
getTriggerType
()
==
TRIGGER_AUTOMATIC
:
if
self
.
_checkTransitionGuard
(
t
,
document
):
tdef
=
t
break
...
...
@@ -268,7 +268,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if
tdef
not
in
self
.
objectValues
(
portal_type
=
'Transition'
):
raise
Unauthorized
(
action
)
if
tdef
is
None
or
tdef
.
trigger_type
!=
TRIGGER_USER_ACTION
:
if
tdef
is
None
or
tdef
.
getTriggerType
()
!=
TRIGGER_USER_ACTION
:
msg
=
_
(
u"Transition '${action_id}' is not triggered by a user "
u"action."
,
mapping
=
{
'action_id'
:
action
})
raise
WorkflowException
(
msg
)
...
...
@@ -311,19 +311,19 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
for
tid
in
sdef
.
getDestinationIdList
():
tdef
=
self
.
_getOb
(
id
=
tid
)
if
tdef
is
not
None
and
tdef
.
trigger_type
==
TRIGGER_USER_ACTION
and
\
tdef
.
actbox_name
and
self
.
_checkTransitionGuard
(
tdef
,
document
):
if
tdef
is
not
None
and
tdef
.
getTriggerType
()
==
TRIGGER_USER_ACTION
and
\
tdef
.
getActboxName
()
and
self
.
_checkTransitionGuard
(
tdef
,
document
):
if
fmt_data
is
None
:
fmt_data
=
TemplateDict
()
fmt_data
.
_push
(
info
)
fmt_data
.
_push
({
'transition_id'
:
tdef
.
getReference
()})
res
.
append
((
tid
,
{
'id'
:
tdef
.
getReference
(),
'name'
:
tdef
.
actbox_name
%
fmt_data
,
'url'
:
str
(
tdef
.
actbox_url
)
%
fmt_data
,
'icon'
:
str
(
tdef
.
actbox_icon
)
%
fmt_data
,
'name'
:
tdef
.
getActboxName
()
%
fmt_data
,
'url'
:
str
(
tdef
.
getActboxUrl
()
)
%
fmt_data
,
'icon'
:
str
(
tdef
.
getActboxIcon
()
)
%
fmt_data
,
'permissions'
:
(),
# Predetermined.
'category'
:
tdef
.
actbox_category
,
'category'
:
tdef
.
getActboxCategory
()
,
'transition'
:
tdef
}))
fmt_data
.
_pop
()
res
.
sort
()
...
...
@@ -429,15 +429,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
getSecurityManager
(),
self
,
ob
):
return
default
status
=
self
.
getCurrentStatusDict
(
ob
)
default_expr
=
vdef
.
getDefaultExpr
()
if
status
is
not
None
and
status
.
has_key
(
name
):
value
=
status
[
name
]
# Not set yet. Use a default.
elif
vdef
.
default_expr
is
not
None
:
elif
default_expr
is
not
None
:
ec
=
createExprContext
(
StateChangeInfo
(
ob
,
self
,
status
))
value
=
Expression
(
vdef
.
default_expr
)(
ec
)
value
=
Expression
(
default_expr
)(
ec
)
else
:
value
=
vdef
.
default_value
value
=
vdef
.
getInitialValue
()
return
value
...
...
@@ -462,7 +463,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
return
status
.
copy
()
def
_getWorkflowStateOf
(
self
,
ob
,
id_only
=
0
):
tool
=
getToolByName
(
self
,
'portal_workflow'
)
tool
=
self
.
getParent
(
)
id_no_suffix
=
self
.
getReference
()
status
=
tool
.
getStatusOf
(
id_no_suffix
,
ob
)
if
status
is
None
:
...
...
@@ -547,7 +548,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if
prefix_method_id
not
in
sdef
.
getDestinationIdList
():
raise
Unauthorized
(
method_id
)
tdef
=
self
.
_getOb
(
prefix_method_id
)
if
tdef
is
None
or
tdef
.
trigger_type
!=
TRIGGER_WORKFLOW_METHOD
:
if
tdef
is
None
or
tdef
.
getTriggerType
()
!=
TRIGGER_WORKFLOW_METHOD
:
raise
WorkflowException
,
(
'Transition %s is not triggered by a workflow method'
%
method_id
)
...
...
@@ -656,14 +657,14 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
for
vdef
in
self
.
objectValues
(
portal_type
=
'Variable'
):
id
=
vdef
.
getId
()
variable_reference
=
vdef
.
getReference
()
if
not
vdef
.
for_status
or
vdef
.
for_status
==
0
:
if
not
vdef
.
getForStatus
()
or
vdef
.
getForStatus
()
==
0
:
continue
expr
=
None
if
variable_reference
in
state_values
:
value
=
state_values
[
variable_reference
]
elif
id
in
tdef_exprs
:
expr
=
tdef_exprs
[
id
]
elif
not
vdef
.
update_always
and
variable_reference
in
former_status
:
elif
not
vdef
.
getAutomaticUpdate
()
and
variable_reference
in
former_status
:
# Preserve former value
value
=
former_status
[
variable_reference
]
else
:
...
...
@@ -716,7 +717,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if
script
:
# Script can be either script or workflow method
if
script_id
in
old_sdef
.
getDestinationIdList
()
and
\
self
.
_getOb
(
script_id
).
trigger_type
==
TRIGGER_WORKFLOW_METHOD
:
self
.
_getOb
(
script_id
).
getTriggerType
()
==
TRIGGER_WORKFLOW_METHOD
:
getattr
(
document
,
convertToMixedCase
(
self
.
_getOb
(
script_id
).
getReference
()))()
else
:
# Pass lots of info to the script in a single parameter.
...
...
@@ -741,7 +742,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if
method_id
not
in
sdef
.
getTransitionIdList
():
raise
Unauthorized
(
method_id
)
tdef
=
self
.
getTransitionValueList
().
get
(
method_id
,
None
)
if
tdef
is
None
or
tdef
.
trigger_type
!=
TRIGGER_WORKFLOW_METHOD
:
if
tdef
is
None
or
tdef
.
getTriggerType
()
!=
TRIGGER_WORKFLOW_METHOD
:
raise
WorkflowException
,
(
'Transition %s is not triggered by a workflow method'
%
method_id
)
...
...
@@ -1056,21 +1057,22 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
tdef_exprs
=
{}
status
=
{}
for
id
,
vdef
in
self
.
getVariableValueList
().
items
():
if
vdef
.
for_status
==
0
:
if
vdef
.
getForStatus
()
==
0
:
continue
expr
=
None
if
state_values
.
has_key
(
id
):
value
=
state_values
[
id
]
elif
tdef_exprs
.
has_key
(
id
):
expr
=
tdef_exprs
[
id
]
elif
not
vdef
.
update_always
and
former_status
.
has_key
(
id
):
elif
not
vdef
.
getAutomaticUpdate
()
and
former_status
.
has_key
(
id
):
# Preserve former value
value
=
former_status
[
id
]
else
:
if
vdef
.
default_expr
is
not
None
:
expr
=
Expression
(
vdef
.
default_expr
)
default_expr
=
vdef
.
getDefaultExpr
()
if
default_expr
is
not
None
:
expr
=
Expression
(
default_expr
)
else
:
value
=
vdef
.
default_value
value
=
vdef
.
getInitialValue
()
if
expr
is
not
None
:
# Evaluate an expression.
if
econtext
is
None
:
...
...
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