Commit b9def522 authored by Romain Courteaud's avatar Romain Courteaud

Clean a little WorkflowTool_wrapWorkflowMethod.

Add some comments.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3701 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6a9c0a44
...@@ -836,11 +836,14 @@ def WorkflowTool_wrapWorkflowMethod(self, ob, method_id, func, args, kw): ...@@ -836,11 +836,14 @@ def WorkflowTool_wrapWorkflowMethod(self, ob, method_id, func, args, kw):
0 or many Interaction workflows. We should take care that the 0 or many Interaction workflows. We should take care that the
method will be called once method will be called once
""" """
# Check workflow containing the workflow method
wf_list = [] wf_list = []
wfs = self.getWorkflowsFor(ob) wfs = self.getWorkflowsFor(ob)
if wfs: if wfs:
for w in wfs: for w in wfs:
#LOG('ERP5WorkflowTool.wrapWorkflowMethod, is wfMSupported', 0, repr(( w.isWorkflowMethodSupported(ob, method_id), w.getId(), ob, method_id ))) # LOG('ERP5WorkflowTool.wrapWorkflowMethod, is wfMSupported', 0,
# repr((w.isWorkflowMethodSupported(ob, method_id),
# w.getId(), ob, method_id )))
if (hasattr(w, 'isWorkflowMethodSupported') if (hasattr(w, 'isWorkflowMethodSupported')
and w.isWorkflowMethodSupported(ob, method_id)): and w.isWorkflowMethodSupported(ob, method_id)):
#wf = w #wf = w
...@@ -848,23 +851,26 @@ def WorkflowTool_wrapWorkflowMethod(self, ob, method_id, func, args, kw): ...@@ -848,23 +851,26 @@ def WorkflowTool_wrapWorkflowMethod(self, ob, method_id, func, args, kw):
wf_list.append(w) wf_list.append(w)
else: else:
wfs = () wfs = ()
# If no transition matched, simply call the method
# And return
if len(wf_list)==0: if len(wf_list)==0:
return apply(func, args, kw) return apply(func, args, kw)
no_interaction = 0 # Call notifyBefore on each workflow
for w in wf_list:
if w.__class__.__name__ != 'InteractionWorkflowDefinition':
no_interaction = 1
for w in wfs: for w in wfs:
w.notifyBefore(ob, method_id, args=args, kw=kw) w.notifyBefore(ob, method_id, args=args, kw=kw)
# Check if there is at least 1 non interaction workflow # Call the method on matching workflows
if no_interaction: only_interaction_defined = 1
for w in wf_list: for w in wf_list:
if w.__class__.__name__ != 'InteractionWorkflowDefinition': if w.__class__.__name__ != 'InteractionWorkflowDefinition':
only_interaction_defined = 0
result = self._invokeWithNotification( result = self._invokeWithNotification(
[], ob, method_id, w.wrapWorkflowMethod, [], ob, method_id, w.wrapWorkflowMethod,
(ob, method_id, func, args, kw), {}) (ob, method_id, func, args, kw), {})
else: # If only interaction workflows are defined, we need to call the method
# manually
if only_interaction_defined:
result = apply(func, args, kw) result = apply(func, args, kw)
# Call notifySuccess on each workflow
for w in wfs: for w in wfs:
w.notifySuccess(ob, method_id, result, args=args, kw=kw) w.notifySuccess(ob, method_id, result, args=args, kw=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