Commit eee71126 authored by wenjie.zheng's avatar wenjie.zheng Committed by Sebastien Robin

Transition.py: add property Reference and varable default _reference.

parent 93212158
...@@ -50,7 +50,7 @@ TRIGGER_AUTOMATIC = 0 ...@@ -50,7 +50,7 @@ TRIGGER_AUTOMATIC = 0
TRIGGER_USER_ACTION = 1 TRIGGER_USER_ACTION = 1
TRIGGER_WORKFLOW_METHOD = 2 TRIGGER_WORKFLOW_METHOD = 2
class Transition(IdAsReferenceMixin('transition_'), XMLObject): class Transition(IdAsReferenceMixin('_transition'), XMLObject):
""" """
A ERP5 Transition. A ERP5 Transition.
""" """
...@@ -67,7 +67,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject): ...@@ -67,7 +67,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject):
actbox_icon = '' actbox_icon = ''
actbox_category = 'workflow' actbox_category = 'workflow'
var_exprs = None # A mapping. var_exprs = None # A mapping.
default_reference = ''
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
...@@ -78,15 +78,10 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject): ...@@ -78,15 +78,10 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject):
PropertySheet.XMLObject, PropertySheet.XMLObject,
PropertySheet.CategoryCore, PropertySheet.CategoryCore,
PropertySheet.DublinCore, PropertySheet.DublinCore,
PropertySheet.Reference,
PropertySheet.Transition, PropertySheet.Transition,
) )
def _getObjectByRef(self, ref):
for ob in self:
if wf.getRef() == ref:
return ob
return None
def getGuardSummary(self): def getGuardSummary(self):
res = None res = None
if self.guard is not None: if self.guard is not None:
...@@ -149,7 +144,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject): ...@@ -149,7 +144,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject):
if state_object == None: if state_object == None:
state_object = workflow.getSourceValue() state_object = workflow.getSourceValue()
old_state = state_object.getId() ### getRef old_state = state_object.getId()
old_sdef = state_object old_sdef = state_object
new_state = self.getDestinationId() new_state = self.getDestinationId()
...@@ -163,7 +158,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject): ...@@ -163,7 +158,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject):
return return
former_status = {} former_status = {}
else: else:
former_status = state_object.getId() ### getRef former_status = state_object.getId()
try: try:
new_sdef = self.getDestinationValue() new_sdef = self.getDestinationValue()
...@@ -174,7 +169,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject): ...@@ -174,7 +169,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject):
before_script_success = 1 before_script_success = 1
script_id = self.getBeforeScriptId() script_id = self.getBeforeScriptId()
if script_id: if script_id:
script = self.getParent()._getOb(script_id) ### _getObjectByRef script = self.getParent()._getOb(script_id)
# Pass lots of info to the script in a single parameter. # Pass lots of info to the script in a single parameter.
kwargs = form_kw kwargs = form_kw
sci = StateChangeInfo( sci = StateChangeInfo(
...@@ -193,7 +188,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject): ...@@ -193,7 +188,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject):
# Do not proceed in case of failure of before script # Do not proceed in case of failure of before script
if not before_script_success: if not before_script_success:
former_status = old_state # Remain in state former_status = old_state # Remain in state
tool.setStatusOf(workflow.getId(), document, status_dict) ### getRef tool.setStatusOf(workflow.getId(), document, status_dict)
sci = StateChangeInfo( sci = StateChangeInfo(
document, workflow, former_status, self, old_sdef, new_sdef, kwargs) document, workflow, former_status, self, old_sdef, new_sdef, kwargs)
# put the error message in the workflow history # put the error message in the workflow history
...@@ -229,7 +224,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject): ...@@ -229,7 +224,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject):
tdef_exprs = {} tdef_exprs = {}
for vdef in workflow.objectValues(portal_type='Variable'): for vdef in workflow.objectValues(portal_type='Variable'):
id = vdef.getId() ### getRef id = vdef.getId()
if vdef.for_status == 0: if vdef.for_status == 0:
continue continue
expr = None expr = None
...@@ -267,7 +262,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject): ...@@ -267,7 +262,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject):
status_dict[variable.getCausalityTitle()] = variable.getInitialValue(object=object) status_dict[variable.getCausalityTitle()] = variable.getInitialValue(object=object)
# Generate Workflow History List # Generate Workflow History List
tool.setStatusOf(workflow.getId(), document, status_dict) ### getRef tool.setStatusOf(workflow.getId(), document, status_dict)
### zwj: update Role mapping, also in Workflow, initialiseDocument() ### zwj: update Role mapping, also in Workflow, initialiseDocument()
workflow.updateRoleMappingsFor(document) workflow.updateRoleMappingsFor(document)
...@@ -280,7 +275,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject): ...@@ -280,7 +275,7 @@ class Transition(IdAsReferenceMixin('transition_'), XMLObject):
if script_id in old_sdef.getDestinationIdList(): if script_id in old_sdef.getDestinationIdList():
getattr(workflow, convertToMixedCase(script_id)).execute(document) getattr(workflow, convertToMixedCase(script_id)).execute(document)
else: else:
script = self.getParent()._getOb(script_id) ### _getObjectByRef script = self.getParent()._getOb(script_id)
# Pass lots of info to the script in a single parameter. # Pass lots of info to the script in a single parameter.
if script.getTypeInfo().getId() == 'Workflow Script': if script.getTypeInfo().getId() == 'Workflow Script':
sci = StateChangeInfo( sci = StateChangeInfo(
......
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