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
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Graydon
erp5
Commits
74e5ca9b
Commit
74e5ca9b
authored
Mar 31, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InteractionWorkflow.py: add initializeDocument and _updateWorkflowHistory.
parent
2a059047
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
3 deletions
+45
-3
product/ERP5Workflow/Document/InteractionWorkflow.py
product/ERP5Workflow/Document/InteractionWorkflow.py
+45
-3
No files found.
product/ERP5Workflow/Document/InteractionWorkflow.py
View file @
74e5ca9b
...
@@ -43,6 +43,7 @@ from Products.DCWorkflow.Expression import StateChangeInfo
...
@@ -43,6 +43,7 @@ from Products.DCWorkflow.Expression import StateChangeInfo
from
Products.ERP5Type.Workflow
import
addWorkflowFactory
from
Products.ERP5Type.Workflow
import
addWorkflowFactory
from
Products.CMFActivity.ActiveObject
import
ActiveObject
from
Products.CMFActivity.ActiveObject
import
ActiveObject
from
Products.ERP5Type.patches.Expression
import
Expression_createExprContext
from
Products.ERP5Type.patches.Expression
import
Expression_createExprContext
from
Products.ERP5Type.Globals
import
PersistentMapping
_MARKER
=
[]
_MARKER
=
[]
...
@@ -79,6 +80,32 @@ class InteractionWorkflow(XMLObject):
...
@@ -79,6 +80,32 @@ class InteractionWorkflow(XMLObject):
PropertySheet
.
InteractionWorkflow
,
PropertySheet
.
InteractionWorkflow
,
)
)
def
initializeDocument
(
self
,
document
):
"""
Set initial state on the Document
zwj:is Interaction Workflow called during the intialization of the object?
"""
state_bc_id
=
'state'
# document.setCategoryMembership(state_bc_id, self.getSource())
object
=
self
.
getStateChangeInformation
(
document
,
self
.
getSourceValue
())
# Initialize workflow history
status_dict
=
{
state_bc_id
:
'current'
}
variable_list
=
self
.
objectValues
(
portal_type
=
'Variable'
)
former_status
=
None
ec
=
Expression_createExprContext
(
StateChangeInfo
(
document
,
self
,
former_status
))
for
variable
in
variable_list
:
if
variable
.
for_status
==
0
:
continue
if
variable
.
default_expr
is
not
None
:
expr
=
Expression
(
variable
.
default_expr
)
value
=
expr
(
ec
)
else
:
value
=
variable
.
getInitialValue
(
object
=
object
)
status_dict
[
variable
.
getId
()]
=
value
self
.
_updateWorkflowHistory
(
document
,
status_dict
)
security
.
declareProtected
(
Permissions
.
View
,
'getChainedPortalTypeList'
)
security
.
declareProtected
(
Permissions
.
View
,
'getChainedPortalTypeList'
)
def
getChainedPortalTypeList
(
self
):
def
getChainedPortalTypeList
(
self
):
"""Returns the list of portal types that are chained to this
"""Returns the list of portal types that are chained to this
...
@@ -146,9 +173,6 @@ class InteractionWorkflow(XMLObject):
...
@@ -146,9 +173,6 @@ class InteractionWorkflow(XMLObject):
tdef
=
self
.
_getOb
(
method_id
,
None
)
tdef
=
self
.
_getOb
(
method_id
,
None
)
return
tdef
is
not
None
and
self
.
_checkTransitionGuard
(
tdef
,
ob
)
return
tdef
is
not
None
and
self
.
_checkTransitionGuard
(
tdef
,
ob
)
def
execute
(
self
):
### zwj: execute interaction, check Transition.py/execute
pass
def
_before_commit
(
self
,
sci
,
script_name
,
security_manager
):
def
_before_commit
(
self
,
sci
,
script_name
,
security_manager
):
# check the object still exists before calling the script
# check the object still exists before calling the script
ob
=
sci
.
object
ob
=
sci
.
object
...
@@ -190,3 +214,21 @@ class InteractionWorkflow(XMLObject):
...
@@ -190,3 +214,21 @@ class InteractionWorkflow(XMLObject):
def
getValidRoleList
(
self
):
def
getValidRoleList
(
self
):
return
sorted
(
self
.
getPortalObject
().
getDefaultModule
(
'acl_users'
).
valid_roles
())
return
sorted
(
self
.
getPortalObject
().
getDefaultModule
(
'acl_users'
).
valid_roles
())
def
_updateWorkflowHistory
(
self
,
document
,
status_dict
):
"""
Change the state of the object.
"""
# Create history attributes if needed
if
getattr
(
aq_base
(
document
),
'workflow_history'
,
None
)
is
None
:
document
.
workflow_history
=
PersistentMapping
()
# XXX this _p_changed is apparently not necessary
document
.
_p_changed
=
1
# Add an entry for the workflow in the history
workflow_key
=
self
.
_generateHistoryKey
()
if
not
document
.
workflow_history
.
has_key
(
workflow_key
):
document
.
workflow_history
[
workflow_key
]
=
()
# Update history
document
.
workflow_history
[
workflow_key
]
+=
(
status_dict
,)
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