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
Hardik Juneja
erp5
Commits
4db022b0
Commit
4db022b0
authored
May 05, 2015
by
wenjie.zheng
Committed by
Sebastien Robin
Jul 16, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transition.py: remove unused function.
parent
724155ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
172 deletions
+0
-172
product/ERP5Workflow/Document/Transition.py
product/ERP5Workflow/Document/Transition.py
+0
-172
No files found.
product/ERP5Workflow/Document/Transition.py
View file @
4db022b0
...
...
@@ -121,178 +121,6 @@ class Transition(IdAsReferenceMixin("transition_", "prefix"), XMLObject):
if
self
.
guard
.
expr
!=
self
.
getExpression
():
self
.
guard
.
expr
=
self
.
getExpression
()
def
execute
(
self
,
document
,
form_kw
=
None
):
"""
Execute transition.
"""
sci
=
None
econtext
=
None
moved_exc
=
None
validation_exc
=
None
tool
=
getToolByName
(
self
,
'portal_workflow'
)
# Figure out the old and new states.
if
form_kw
is
None
:
form_kw
=
{}
workflow
=
self
.
getParentValue
()
### get related history
state_var
=
workflow
.
getStateVariable
()
status_dict
=
workflow
.
getCurrentStatusDict
(
document
)
state_object
=
workflow
.
_getWorkflowStateOf
(
document
,
id_only
=
0
)
if
state_object
==
None
:
state_object
=
workflow
.
getSourceValue
()
old_state
=
state_object
.
getReference
()
old_sdef
=
state_object
new_sdef
=
self
.
getDestinationValue
()
if
new_sdef
==
None
:
new_state
=
None
else
:
new_state
=
new_sdef
.
getReference
()
if
new_state
is
None
:
#new_state = workflow.getSourceId()
new_state
=
old_state
if
not
new_state
:
# Do nothing if there is no initial state. We may want to create
# workflows with no state at all, only for worklists.
return
former_status
=
{}
else
:
former_status
=
state_object
.
getId
()
LOG
(
" 168 object '%s' will change from state '%s' to '%s'"
%
(
document
.
getId
(),
old_state
,
new_state
),
WARNING
,
" in Transition.py"
)
# Execute the "before" script.
before_script_success
=
1
script_id
=
self
.
getBeforeScriptId
()
if
script_id
:
script
=
self
.
getParent
().
_getOb
(
script_id
)
# Pass lots of info to the script in a single parameter.
kwargs
=
form_kw
sci
=
StateChangeInfo
(
document
,
workflow
,
former_status
,
self
,
old_sdef
,
new_sdef
,
kwargs
)
try
:
#LOG('_executeTransition', 0, "script = %s, sci = %s" % (repr(script), repr(sci)))
script
.
execute
(
sci
)
# May throw an exception.
except
ValidationFailed
,
validation_exc
:
before_script_success
=
0
before_script_error_message
=
deepcopy
(
validation_exc
.
msg
)
validation_exc_traceback
=
sys
.
exc_traceback
except
ObjectMoved
,
moved_exc
:
ob
=
moved_exc
.
getNewObject
()
# Re-raise after transition
# Do not proceed in case of failure of before script
if
not
before_script_success
:
former_status
=
old_state
# Remain in state
tool
.
setStatusOf
(
workflow
.
getReference
(),
document
,
status_dict
)
sci
=
StateChangeInfo
(
document
,
workflow
,
former_status
,
self
,
old_sdef
,
new_sdef
,
kwargs
)
# put the error message in the workflow history
sci
.
setWorkflowVariable
(
error_message
=
before_script_error_message
)
if
validation_exc
:
# reraise validation failed exception
raise
validation_exc
,
None
,
validation_exc_traceback
return
old_state
# update state
state
=
self
.
getDestination
()
if
state
is
None
:
state
=
old_sdef
state_var
=
workflow
.
getStateVariable
()
#document.setCategoryMembership(state_var, state)
status_dict
[
'undo'
]
=
0
# Modify workflow history
status_dict
[
state_var
]
=
new_state
object
=
workflow
.
getStateChangeInformation
(
document
,
state_object
,
transition
=
self
)
# update variables =========================================================
state_values
=
None
if
new_sdef
is
not
None
:
state_values
=
new_sdef
.
objectValues
(
portal_type
=
'Variable'
)
if
state_values
is
None
:
state_values
=
{}
tdef_exprs
=
self
.
objectValues
(
portal_type
=
'Variable'
)
if
tdef_exprs
is
None
:
tdef_exprs
=
{}
for
vdef
in
workflow
.
objectValues
(
portal_type
=
'Variable'
):
id
=
vdef
.
getId
()
id_no_suffix
=
vdef
.
getReference
()
if
vdef
.
for_status
==
0
:
continue
expr
=
None
if
id_no_suffix
in
state_values
:
value
=
state_values
[
id_no_suffix
]
elif
id
in
tdef_exprs
:
expr
=
tdef_exprs
[
id
]
elif
not
vdef
.
update_always
and
id
in
former_status
:
# Preserve former value
value
=
former_status
[
id
]
else
:
if
vdef
.
default_expr
is
not
None
:
expr
=
vdef
.
default_expr
else
:
value
=
vdef
.
default_value
if
expr
is
not
None
:
# Evaluate an expression.
if
econtext
is
None
:
# Lazily create the expression context.
if
sci
is
None
:
kwargs
=
form_kw
sci
=
StateChangeInfo
(
document
,
workflow
,
former_status
,
self
,
old_sdef
,
new_sdef
,
kwargs
)
econtext
=
Expression_createExprContext
(
sci
)
expr
=
Expression
(
expr
)
value
=
expr
(
econtext
)
if
id_no_suffix
==
"action"
:
status_dict
[
id_no_suffix
]
=
'_'
.
join
(
value
.
split
(
'_'
)[
1
:])
else
:
status_dict
[
id_no_suffix
]
=
value
# Update all transition variables
if
form_kw
is
not
None
:
object
.
REQUEST
.
other
.
update
(
form_kw
)
for
variable
in
self
.
objectValues
(
portal_type
=
'Transition Variable'
):
status_dict
[
variable
.
getCausalityTitle
()]
=
variable
.
getInitialValue
(
object
=
object
)
# Generate Workflow History List
tool
.
setStatusOf
(
workflow
.
getReference
(),
document
,
status_dict
)
### zwj: update Role mapping, also in Workflow, initialiseDocument()
workflow
.
updateRoleMappingsFor
(
document
)
# Execute the "after" script.
script_id
=
self
.
getAfterScriptId
()
if
script_id
is
not
None
:
kwargs
=
form_kw
# Script can be either script or workflow method
if
script_id
in
old_sdef
.
getDestinationIdList
():
getattr
(
workflow
,
script_id
).
execute
(
document
)
else
:
script
=
self
.
getParent
().
_getOb
(
script_id
)
# Pass lots of info to the script in a single parameter.
if
script
.
getTypeInfo
().
getId
()
==
'Workflow Script'
:
sci
=
StateChangeInfo
(
document
,
workflow
,
former_status
,
self
,
old_sdef
,
new_sdef
,
kwargs
)
script
.
execute
(
sci
)
# May throw an exception.
else
:
raise
NotImplementedError
(
'Unsupported Script %s for state %s'
%
(
script_id
,
old_sdef
.
getId
()))
### getRef
# Return the new state object.
if
moved_exc
is
not
None
:
# Propagate the notification that the object has moved.
raise
moved_exc
else
:
return
new_sdef
def
_checkPermission
(
self
,
document
):
"""
Check if transition is allowed.
...
...
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