Commit 7e6420dd authored by wenjie.zheng's avatar wenjie.zheng

Workflow.py: remove non necessary code in notifyCreated; fix...

Workflow.py: remove non necessary code in notifyCreated; fix _executeTransition when non transition pass to it as a parameter.
parent 904139f8
......@@ -95,32 +95,14 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
)
def notifyCreated(self, document):
"""
Set initial state on the Document
"""
state_var = self.getStateVariable()
object = self.getStateChangeInformation(document, self.getSourceValue())
# Initialize workflow history
state_id = self.getSourceValue().getReference()
status_dict = {state_var: state_id}
variable_list = self.objectValues(portal_type='Variable')
former_status = self._getOb(status_dict[state_var], None)
ec = 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)
if value is None: value = ''
status_dict[variable.getReference()] = value
self._updateWorkflowHistory(document, status_dict)
self.updateRoleMappingsFor(document)
"""Notifies this workflow after an object has been created and added.
"""
try:
self._changeStateOf(document, None)
except ( ObjectDeleted, ObjectMoved ):
# Swallow.
pass
initializeDocument = notifyCreated
......@@ -613,7 +595,8 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if tdef is None:
new_sdef = self.getSourceValue()
if not new_state:
new_state = new_sdef.getReference()
if not new_sdef:
return
former_status = {}
else:
......@@ -654,6 +637,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if state_values is None: state_values = {}
tdef_exprs = {}
transition_variable_list = []
if tdef is not None:
transition_variable_list = tdef.objectValues(portal_type='Transition Variable')
for transition_variable in transition_variable_list:
......@@ -719,6 +703,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
self.updateRoleMappingsFor(document)
# Execute the "after" script.
if tdef is not None:
script_id = getattr(tdef, 'getAfterScriptId')()
if script_id is not None:
kwargs = form_kw
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment