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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5
Commits
2a059047
Commit
2a059047
authored
Mar 31, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Interaction.py: add script execution and workflow history generation codes.
parent
14dd398d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
9 deletions
+52
-9
product/ERP5Workflow/Document/Interaction.py
product/ERP5Workflow/Document/Interaction.py
+52
-9
No files found.
product/ERP5Workflow/Document/Interaction.py
View file @
2a059047
...
...
@@ -25,7 +25,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
transaction
from
AccessControl
import
getSecurityManager
,
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type.XMLObject
import
XMLObject
...
...
@@ -128,15 +128,31 @@ class Interaction(XMLObject):
workflow
=
self
.
getParent
()
assert
self
.
trigger_type
==
TRIGGER_WORKFLOW_METHOD
status
=
workflow
.
getCurrentStatusDict
(
ob
)
# execute before script
for
script_name
in
self
.
script_name
:
script
=
workflow
.
_getOb
(
script_name
)
# Pass lots of info to the script in a single parameter.
script
(
sci
)
# Initialize variables
former_status
=
workflow
.
_getStatusOf
(
ob
)
former_status
=
None
econtext
=
None
sci
=
None
sci
=
StateChangeInfo
(
ob
,
worfklow
,
former_status
,
self
,
None
,
None
,
kwargs
=
kw
)
# Execute before script
before_script_success
=
1
for
script_name
in
self
.
getBeforeScriptName
():
script
=
workflow
.
_getOb
(
script_name
)
# Pass lots of info to the script in a single parameter.
script
(
sci
)
# Update variables.
tdef_exprs
=
self
.
var_exprs
if
tdef_exprs
is
None
:
tdef_exprs
=
{}
status
=
{}
for
vdef
in
workflow
.
objectValues
(
portal_type
=
'Variable'
):
id
=
vdef
.
getId
()
if
not
vdef
.
for_status
:
...
...
@@ -160,26 +176,26 @@ class Interaction(XMLObject):
sci
=
StateChangeInfo
(
ob
,
workflow
,
former_status
,
self
,
None
,
None
,
None
)
econtext
=
createExprContext
(
sci
)
econtext
=
Expression_
createExprContext
(
sci
)
value
=
expr
(
econtext
)
status
[
id
]
=
value
s
ci
=
StateChangeInfo
(
ob
,
worfklow
,
former_status
,
self
,
None
,
None
,
kwargs
=
kw
)
s
elf
.
setStatusOf
(
workflow
.
getId
(),
ob
,
status
)
# Execute the "after" script.
for
script_name
in
self
.
after_script_name
:
for
script_name
in
self
.
getAfterScriptName
()
:
script
=
workflow
.
_getOb
(
script_name
)
# Pass lots of info to the script in a single parameter.
script
(
sci
)
# May throw an exception
# Queue the "Before Commit" scripts
sm
=
getSecurityManager
()
for
script_name
in
self
.
before_commit_script_name
:
for
script_name
in
self
.
getBeforeCommitScriptName
()
:
transaction
.
get
().
addBeforeCommitHook
(
self
.
_before_commit
,
(
sci
,
script_name
,
sm
))
# Execute "activity" scripts
for
script_name
in
self
.
activate_script_name
:
for
script_name
in
self
.
getActivityScriptName
()
:
workflow
.
activate
(
activity
=
'SQLQueue'
)
\
.
activeScript
(
script_name
,
ob
.
getRelativeUrl
(),
status
,
self
.
getId
())
...
...
@@ -222,3 +238,30 @@ class Interaction(XMLObject):
def
getWorkflow
(
self
):
return
aq_parent
(
aq_inner
(
aq_parent
(
aq_inner
(
self
))))
def
setStatusOf
(
self
,
wf_id
,
ob
,
status
):
""" Append an entry to the workflow history.
o Invoked by transition execution.
"""
wfh
=
None
has_history
=
0
if
getattr
(
aq_base
(
ob
),
'workflow_history'
,
None
)
is
not
None
:
history
=
ob
.
workflow_history
if
history
is
not
None
:
has_history
=
1
wfh
=
history
.
get
(
wf_id
,
None
)
if
wfh
is
not
None
and
not
isinstance
(
wfh
,
WorkflowHistoryList
):
wfh
=
WorkflowHistoryList
(
list
(
wfh
))
ob
.
workflow_history
[
wf_id
]
=
wfh
if
wfh
is
None
:
wfh
=
WorkflowHistoryList
()
if
not
has_history
:
ob
.
workflow_history
=
PersistentMapping
()
ob
.
workflow_history
[
wf_id
]
=
wfh
wfh
.
append
(
status
)
"""
if not has_history:
ob.workflow_history = PersistentMapping()
ob.workflow_history[wf_id] = tuple(wfh)
"""
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