def setupActions(self): return # !+ ?? wfc = interfaces.IWorkflowController(self.context, None) if wfc is not None: transitions = wfc.getManualTransitionIds() self.actions = tuple( bindTransitions(self, transitions, wfc.workflow))
def fireAutomaticTransitions(object, event): """Fire automatic transitions for a new state. event:bungeni.core.workflow.interfaces.IWorkflowTransitionEvent """ wfc = interfaces.IWorkflowController(object, None) if wfc is not None: wfc.fireAutomatic()
def setupActions(self, transition_id): # !+RENAME(mr, apr-2011) should be transition_id wfc = interfaces.IWorkflowController(self.context) if transition_id is None: transition_ids = wfc.getManualTransitionIds() else: transition_ids = (transition_id, ) self.actions = bindTransitions(self, transition_ids, wfc.workflow)
def initializeWorkflow(object, event): """In response to object created events. event:zope.lifecycleevent.ObjectCreatedEvent """ if interfaces.IWorkflow(object, None) is None: return workflow = interfaces.IWorkflowController(object, None) if workflow is not None: workflow.fireAutomatic()
def setupActions(self, transition): # !+RENAME(mr, apr-2011) should be transition_id wfc = interfaces.IWorkflowController(self.context) if transition is None: transitions = wfc.getManualTransitionIds() else: transitions = (transition,) self.actions = bindTransitions(self, transitions, None, wfc.workflow) if IWorkspaceContainer.providedBy(self.context.__parent__): self._next_url = absoluteURL(self.context.__parent__, self.request)
def __call__(self, form, action, data): """Save data, make version and fire transition. Redirects to the ``next_url`` location. """ result = handle_edit_action(form, action, data) if form.errors: return result else: context = getattr(form.context, "_object", form.context) log.debug(""" TransitionHandler.__call__() form=%s action=(name=%s, label=%s) data=%s principal_id=%s context=%s transition_id=%s result=%s next_url=%s current_url=%s """ % (form, action.label, action.name, data, get_principal_id(), context, self.transition_id, result, form.next_url, form.request.getURL()) ) # dress-up transition data object data.setdefault("note", data.get("note", "")) data.setdefault("date_active", data.get("date_active", None)) data.setdefault("registry_number", data.get("registry_number", "")) reg_number = data.get("registry_number","") if reg_number: unproxied_context = removeSecurityProxy(context) unproxied_context.registry_number = reg_number # !+ because WorkflowController API e.g. fireTransition(), ONLY # foresees for a comment attribute as additional data, we bypass # using that altogether, and pass it along downstream by stuffing # onto the request IAnnotations(form.request)["change_data"] = data interfaces.IWorkflowController(context).fireTransition( self.transition_id) # NOTE: for some reason form.next_url is (always?) None -- # in which case we redirect to HTTP_REFERER instead. next_url = form.next_url if next_url is None: next_url = form.request["HTTP_REFERER"] log.error(" TransitionHandler.__call__() => CANNOT redirect to " "next_url [None]... will try instead to redirect to " "HTTP_REFERER [%s]" % (next_url,)) return form.request.response.redirect(next_url)