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
Labels
Merge Requests
142
Merge Requests
142
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
cf598640
Commit
cf598640
authored
Dec 12, 2014
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Base.py(merged):Call and Execute Erp5workflow Methods.
parent
94499b78
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
73 deletions
+45
-73
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+45
-73
No files found.
product/ERP5Type/Base.py
View file @
cf598640
...
...
@@ -168,20 +168,17 @@ class WorkflowMethod(Method):
# should be executed. - XXX
return
self
.
_m
(
instance
,
*
args
,
**
kw
)
#=============== Workflow5 Project, Wenjie, Dec 2014 =====================
wf5_module
=
instance
.
getPortalObject
().
getDefaultModule
(
portal_type
=
"Workflow"
)
### this variable contains the methods which will be invoked once
transactional_variable
=
getTransactionalVariable
()
# Build a list of transitions which may need to be invoked
instance_path
=
instance
.
getPhysicalPath
()
portal_type
=
instance
.
portal_type
invoke_once_dict
=
self
.
_invoke_once
.
get
(
portal_type
,{})
transactional_variable
=
getTransactionalVariable
()
invoke_once_dict
=
self
.
_invoke_once
.
get
(
portal_type
,
{})
valid_invoke_once_item_list
=
[]
# Only keep those transitions which were never invoked
once_transition_dict
=
{}
# New implementation does not use any longer wrapWorkflowMethod
# but directly calls the workflow methods
### only execute this part when the instance has erp5workflow defined
if
instance
.
getTypeInfo
().
getTypeWorkflowList
()
!=
[]:
### invoke_once and invoke_aways methods will be put in a list of methods
### which may be invoked.
for
wf_id
,
transition_list
in
invoke_once_dict
.
iteritems
():
valid_transition_list
=
[]
for
transition_id
in
transition_list
:
...
...
@@ -195,14 +192,20 @@ class WorkflowMethod(Method):
candidate_transition_item_list
=
valid_invoke_once_item_list
+
\
self
.
_invoke_always
.
get
(
portal_type
,
{}).
items
()
#LOG('candidate_transition_item_list %s' % self.__name__, 0, str(candidate_transition_item_list))
# Try to return immediately if there are no transition to invoke
if
not
candidate_transition_item_list
:
return
apply
(
self
.
__dict__
[
'_m'
],
(
instance
,)
+
args
,
kw
)
#=============== Workflow5 Project, Wenjie, Dec 2014 =====================
### Access the ERP5Type workflow_list
if
instance
.
getTypeInfo
().
getTypeWorkflowList
()
!=
[]:
### Build the list of method which is call and will be invoked.
valid_transition_item_list
=
[]
for
wf_id
,
transition_list
in
candidate_transition_item_list
:
valid_list
=
[]
for
transition_id
in
transition_list
:
valid_list
.
append
(
transition_id
)
once_transition_key
=
once_transition_dict
.
get
((
wf_id
,
transition_id
))
...
...
@@ -213,20 +216,16 @@ class WorkflowMethod(Method):
for
wf_id
,
transition_list
in
valid_transition_item_list
:
for
tr
in
transition_list
:
#raise NotImplementedError (tr)
method5
=
wf5_module
.
_getOb
(
wf_id
).
_getOb
(
tr
)
method5
=
instance
.
getPortalObject
().
getDefaultModule
(
portal_type
=
"Workflow"
)
.
_getOb
(
wf_id
).
_getOb
(
tr
)
method5
.
execute
(
instance
)
#=================================== wf5 =================================
# Build a list of transitions which may need to be invoked
instance_path
=
instance
.
getPhysicalPath
()
portal_type
=
instance
.
portal_type
transactional_variable
=
getTransactionalVariable
()
invoke_once_dict
=
self
.
_invoke_once
.
get
(
portal_type
,
{})
valid_invoke_once_item_list
=
[]
# Only keep those transitions which were never invoked ?? wj:what does it mean?
once_transition_dict
=
{}
# New implementation does not use any longer wrapWorkflowMethod
# but directly calls the workflow methods
# Prepare a list of transitions which should be invoked.
# This list is based on the results of isWorkflowMethodSupported.
# An interaction is ignored if the guard prevents execution.
# Otherwise, an exception is raised if the workflow transition does not
# exist from the current state, or if the guard rejects it.
try
:
try
:
wf
=
getattr
(
instance
.
getPortalObject
(),
'portal_workflow'
)
# portal_workflow is a list!
except
AttributeError
:
...
...
@@ -234,36 +233,10 @@ class WorkflowMethod(Method):
# XXX I must think that what is a correct behavior.(Yusei)
return
self
.
_m
(
instance
,
*
args
,
**
kw
)
try
:
for
wf_id
,
transition_list
in
invoke_once_dict
.
iteritems
():
valid_transition_list
=
[]
for
transition_id
in
transition_list
:
once_transition_key
=
(
'Products.ERP5Type.Base.WorkflowMethod.__call__'
,
wf_id
,
transition_id
,
instance_path
)
once_transition_dict
[(
wf_id
,
transition_id
)]
=
once_transition_key
if
once_transition_key
not
in
transactional_variable
:
valid_transition_list
.
append
(
transition_id
)
if
valid_transition_list
:
valid_invoke_once_item_list
.
append
((
wf_id
,
valid_transition_list
))
candidate_transition_item_list
=
valid_invoke_once_item_list
+
\
self
.
_invoke_always
.
get
(
portal_type
,
{}).
items
()
#LOG('candidate_transition_item_list %s' % self.__name__, 0, str(candidate_transition_item_list))
# Try to return immediately if there are no transition to invoke
if
not
candidate_transition_item_list
:
return
apply
(
self
.
__dict__
[
'_m'
],
(
instance
,)
+
args
,
kw
)
# Prepare a list of transitions which should be invoked.
# This list is based on the results of isWorkflowMethodSupported.
# An interaction is ignored if the guard prevents execution.
# Otherwise, an exception is raised if the workflow transition does not
# exist from the current state, or if the guard rejects it.
valid_transition_item_list
=
[]
for
wf_id
,
transition_list
in
candidate_transition_item_list
:
candidate_workflow
=
wf
[
wf_id
]
valid_list
=
[]
candidate_workflow
=
wf
[
wf_id
]
for
transition_id
in
transition_list
:
if
candidate_workflow
.
isWorkflowMethodSupported
(
instance
,
transition_id
):
valid_list
.
append
(
transition_id
)
...
...
@@ -310,13 +283,12 @@ class WorkflowMethod(Method):
# Return result finally
return
result
except
:
pass
# Interactions should not be disabled during normal operation. Only in very
# rare and specific cases like data migration. That's why it is implemented
# with temporary monkey-patching, instead of slowing down __call__ with yet
# another condition.
except
:
pass
_do_interaction
=
__call__
_no_interaction_lock
=
threading
.
Lock
()
_no_interaction_log
=
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