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,37 +836,43 @@ def WorkflowTool_wrapWorkflowMethod(self, ob, method_id, func, args, kw): ...@@ -836,37 +836,43 @@ 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,
if (hasattr(w, 'isWorkflowMethodSupported') # repr((w.isWorkflowMethodSupported(ob, method_id),
and w.isWorkflowMethodSupported(ob, method_id)): # w.getId(), ob, method_id )))
#wf = w if (hasattr(w, 'isWorkflowMethodSupported')
#break and w.isWorkflowMethodSupported(ob, method_id)):
wf_list.append(w) #wf = w
#break
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 wfs:
w.notifyBefore(ob, method_id, args=args, kw=kw)
# Call the method on matching workflows
only_interaction_defined = 1
for w in wf_list: for w in wf_list:
if w.__class__.__name__ != 'InteractionWorkflowDefinition': if w.__class__.__name__ != 'InteractionWorkflowDefinition':
no_interaction = 1 only_interaction_defined = 0
for w in wfs: result = self._invokeWithNotification(
w.notifyBefore(ob, method_id, args=args, kw=kw) [], ob, method_id, w.wrapWorkflowMethod,
# Check if there is at least 1 non interaction workflow (ob, method_id, func, args, kw), {})
if no_interaction: # If only interaction workflows are defined, we need to call the method
for w in wf_list: # manually
if w.__class__.__name__ != 'InteractionWorkflowDefinition': if only_interaction_defined:
result = self._invokeWithNotification(
[], ob, method_id, w.wrapWorkflowMethod,
(ob, method_id, func, args, kw), {})
else:
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)
WorkflowTool.wrapWorkflowMethod = WorkflowTool_wrapWorkflowMethod WorkflowTool.wrapWorkflowMethod = WorkflowTool_wrapWorkflowMethod
......
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