Commit 3052a987 authored by wenjie.zheng's avatar wenjie.zheng

WorkflowTool.py: fix worklist generation, and cleanup.

parent c9113ee2
...@@ -696,12 +696,12 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -696,12 +696,12 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
worklist_dict = {} worklist_dict = {}
document = info.object document = info.object
if document:
document_pt = document.getTypeInfo() document_pt = document.getTypeInfo()
if document_pt is not None: if document_pt is not None:
workflow_list = self.getWorkflowValueListFor(document.getPortalType()) workflow_list = self.getWorkflowValueListFor(document.getPortalType())
for wf in workflow_list: for wf in workflow_list:
LOG("Check workflow '%s' action list"%wf.id,WARNING," in WorkflowTool.py 705")
wf_id = wf.getReference() wf_id = wf.getReference()
did[wf_id] = None did[wf_id] = None
wf = self.getPortalObject().portal_workflow._getOb(wf_id, None) wf = self.getPortalObject().portal_workflow._getOb(wf_id, None)
...@@ -1289,56 +1289,6 @@ class WorkflowHistoryList(Persistent): ...@@ -1289,56 +1289,6 @@ class WorkflowHistoryList(Persistent):
self._prev = self.__class__(self._slots, prev=self._prev) self._prev = self.__class__(self._slots, prev=self._prev)
self._slots = [value] self._slots = [value]
def DCWorkflowDefinition_notifyWorkflowMethod(self, ob, transition_list, args=None, kw=None):
'''
Allows the system to request a workflow action. This method
must perform its own security checks.
'''
if type(transition_list) in StringTypes:
method_id = transition_list
elif len(transition_list) == 1:
method_id = transition_list[0]
else:
raise ValueError('WorkflowMethod should be attached to exactly 1 transition per DCWorkflow instance.')
sdef = self._getWorkflowStateOf(ob)
if sdef is None:
raise WorkflowException, 'Object is in an undefined state'
if method_id not in sdef.transitions:
raise Unauthorized(method_id)
tdef = self.transitions.get(method_id, None)
if tdef is None or tdef.trigger_type != TRIGGER_WORKFLOW_METHOD:
raise WorkflowException, (
'Transition %s is not triggered by a workflow method'
% method_id)
if not self._checkTransitionGuard(tdef, ob):
raise Unauthorized(method_id)
self._changeStateOf(ob, tdef, kw)
if getattr(ob, 'reindexObject', None) is not None:
if kw is not None:
activate_kw = kw.get('activate_kw', {})
else:
activate_kw = {}
ob.reindexObject(activate_kw=activate_kw)
def DCWorkflowDefinition_notifyBefore(self, ob, transition_list, args=None, kw=None):
'''
Notifies this workflow of an action before it happens,
allowing veto by exception. Unless an exception is thrown, either
a notifySuccess() or notifyException() can be expected later on.
The action usually corresponds to a method name.
'''
pass
def DCWorkflowDefinition_notifySuccess(self, ob, transition_list, result, args=None, kw=None):
'''
Notifies this workflow that an action has taken place.
'''
pass
DCWorkflowDefinition.notifyWorkflowMethod = DCWorkflowDefinition_notifyWorkflowMethod
DCWorkflowDefinition.notifyBefore = DCWorkflowDefinition_notifyBefore
DCWorkflowDefinition.notifySuccess = DCWorkflowDefinition_notifySuccess
WORKLIST_METADATA_KEY = 'metadata' WORKLIST_METADATA_KEY = 'metadata'
SECURITY_PARAMETER_ID = 'local_roles' SECURITY_PARAMETER_ID = 'local_roles'
COUNT_COLUMN_TITLE = 'count' COUNT_COLUMN_TITLE = 'count'
......
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