def _invokeWithNotification(self, wfs, ob, action, func, args, kw): """ Private utility method: call 'func', and deal with exceptions indicating that the object has been deleted or moved. """ reindex = 1 for w in wfs: w.notifyBefore(ob, action) notify(ActionWillBeInvokedEvent(ob, w, action)) try: res = func(*args, **kw) except ObjectDeleted as ex: res = ex.getResult() reindex = 0 except ObjectMoved as ex: res = ex.getResult() ob = ex.getNewObject() except Exception: exc = sys.exc_info() try: for w in wfs: w.notifyException(ob, action, exc) notify(ActionRaisedExceptionEvent(ob, w, action, exc)) raise exc[0](exc[1]).with_traceback(exc[2]) finally: exc = None for w in wfs: w.notifySuccess(ob, action, res) notify(ActionSucceededEvent(ob, w, action, res)) if reindex: self._reindexWorkflowVariables(ob) return res
def notifyException(self, ob, action, exc): """ Notify all applicable workflows that an action failed. """ wfs = self.getWorkflowsFor(ob) for wf in wfs: wf.notifyException(ob, action, exc) notify(ActionRaisedExceptionEvent(ob, wf, action, exc))
def _invokeWithNotification(self, wfs, ob, action, func, args, kw): """ Private utility method: call 'func', and deal with exceptions indicating that the object has been deleted or moved. """ from zope.event import notify from Products.CMFCore.WorkflowCore import ActionRaisedExceptionEvent from Products.CMFCore.WorkflowCore import ActionSucceededEvent from Products.CMFCore.WorkflowCore import ActionWillBeInvokedEvent from Products.CMFCore.WorkflowCore import ObjectDeleted from Products.CMFCore.WorkflowCore import ObjectMoved from Products.CMFCore.WorkflowCore import WorkflowException reindex = 1 for w in wfs: w.notifyBefore(ob, action) notify(ActionWillBeInvokedEvent(ob, w, action)) try: res = func(*args, **kw) except ObjectDeleted as ex: res = ex.getResult() reindex = 0 except ObjectMoved as ex: res = ex.getResult() ob = ex.getNewObject() except: import sys exc = sys.exc_info() try: for w in wfs: w.notifyException(ob, action, exc) notify(ActionRaisedExceptionEvent(ob, w, action, exc)) reraise(*exc) finally: exc = None for w in wfs: w.notifySuccess(ob, action, res) notify(ActionSucceededEvent(ob, w, action, res)) if reindex: self._reindexWorkflowVariables(ob) return res
notify(ActionWillBeInvokedEvent(ob, w, action)) try: res = func(*args, **kw) except ObjectDeleted, ex: res = ex.getResult() reindex = 0 except ObjectMoved, ex: res = ex.getResult() ob = ex.getNewObject() except: import sys exc = sys.exc_info() try: for w in wfs: w.notifyException(ob, action, exc) notify(ActionRaisedExceptionEvent(ob, w, action, exc)) reraise(*exc) finally: exc = None for w in wfs: w.notifySuccess(ob, action, res) notify(ActionSucceededEvent(ob, w, action, res)) if reindex: self._reindexWorkflowVariables(ob) return res security.declarePublic('doActionFor') def doActionFor(self, ob, action, wf_id=None, *args, **kw): workflow_id = wf_id workflow_list = self.getWorkflowValueListFor(ob.getPortalType())