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 notifyBefore(self, ob, action): """ Notify all applicable workflows of an action before it happens. """ wfs = self.getWorkflowsFor(ob) for wf in wfs: wf.notifyBefore(ob, action) notify(ActionWillBeInvokedEvent(ob, wf, action))
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, ex: res = ex.getResult() reindex = 0
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, ex: res = ex.getResult() reindex = 0
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