def doActionFor(self, ob, action, wf_id=None, *args, **kw): ''' Invoked by user interface code. Allows the user to request a workflow action. The workflow object must perform its own security checks. ''' wfs = self.getWorkflowsFor(ob) if wfs is None: wfs = () if wf_id is None: if not wfs: raise WorkflowException('No workflows found.') found = 0 for wf in wfs: if wf.isActionSupported(ob, action): found = 1 break if not found: raise WorkflowException( 'No workflow provides the "%s" action.' % action) else: wf = self.getWorkflowById(wf_id) if wf is None: raise WorkflowException( 'Requested workflow definition not found.') return self._invokeWithNotification(wfs, ob, action, wf.doActionFor, (ob, action) + args, kw)
def getInfoFor(self, ob, name, default=_marker, wf_id=None, *args, **kw): """ Get the given bit of workflow information for the object. """ if wf_id is None: wfs = self.getWorkflowsFor(ob) if wfs is None: if default is _marker: raise WorkflowException(_(u'No workflows found.')) else: return default found = 0 for wf in wfs: if wf.isInfoSupported(ob, name): found = 1 break if not found: if default is _marker: msg = _(u"No workflow provides '${name}' information.", mapping={'name': name}) raise WorkflowException(msg) else: return default else: wf = self.getWorkflowById(wf_id) if wf is None: if default is _marker: raise WorkflowException( _(u'Requested workflow definition not found.')) else: return default res = wf.getInfoFor(ob, name, default, *args, **kw) if res is _marker: msg = _(u'Could not get info: ${name}', mapping={'name': name}) raise WorkflowException(msg) return res
def doActionFor(self, ob, action, wf_id=None, *args, **kw): """ Perform the given workflow action on 'ob'. """ wfs = self.getWorkflowsFor(ob) if wfs is None: wfs = () if wf_id is None: if not wfs: raise WorkflowException(_(u'No workflows found.')) found = 0 for wf in wfs: if wf.isActionSupported(ob, action, **kw): found = 1 break if not found: msg = _(u"No workflow provides the '${action_id}' action.", mapping={'action_id': action}) raise WorkflowException(msg) else: wf = self.getWorkflowById(wf_id) if wf is None: raise WorkflowException( _(u'Requested workflow definition not found.')) return self._invokeWithNotification(wfs, ob, action, wf.doActionFor, (ob, action) + args, kw)
def doActionFor(self, ob, action, wf_id=None, *args, **kw): """ Execute the given workflow action for the object. o Invoked by user interface code. o Allows the user to request a workflow action. o The workflow object must perform its own security checks. """ wfs = self.getWorkflowsFor(ob) if wfs is None: wfs = () if wf_id is None: if not wfs: raise WorkflowException(_(u'No workflows found.')) found = 0 for wf in wfs: if wf.isActionSupported(ob, action, **kw): found = 1 break if not found: msg = _(u"No workflow provides the '${action_id}' action.", mapping={'action_id': action}) raise WorkflowException(msg) else: wf = self.getWorkflowById(wf_id) if wf is None: raise WorkflowException( _(u'Requested workflow definition not found.')) return self._invokeWithNotification(wfs, ob, action, wf.doActionFor, (ob, action) + args, kw)
def getInfoFor(self, ob, name, default=_marker, wf_id=None, *args, **kw): """ Return a given workflow-specific property for an object. o Invoked by user interface code. o Allows the user to request information provided by the workflow. o The workflow object must perform its own security checks. """ if wf_id is None: wfs = self.getWorkflowsFor(ob) if wfs is None: if default is _marker: raise WorkflowException(_(u'No workflows found.')) else: return default found = 0 for wf in wfs: if wf.isInfoSupported(ob, name): found = 1 break if not found: if default is _marker: msg = _(u"No workflow provides '${name}' information.", mapping={'name': name}) raise WorkflowException(msg) else: return default else: wf = self.getWorkflowById(wf_id) if wf is None: if default is _marker: raise WorkflowException( _(u'Requested workflow definition not found.')) else: return default res = wf.getInfoFor(ob, name, default, *args, **kw) if res is _marker: msg = _(u'Could not get info: ${name}', mapping={'name': name}) raise WorkflowException(msg) return res
def getInfoFor(self, ob, name, default=_marker, wf_id=None, *args, **kw): ''' Invoked by user interface code. Allows the user to request information provided by the workflow. The workflow object must perform its own security checks. ''' if wf_id is None: wfs = self.getWorkflowsFor(ob) if wfs is None: if default is _marker: raise WorkflowException('No workflows found.') else: return default found = 0 for wf in wfs: if wf.isInfoSupported(ob, name): found = 1 break if not found: if default is _marker: raise WorkflowException( 'No workflow provides "%s" information.' % name) else: return default else: wf = self.getWorkflowById(wf_id) if wf is None: if default is _marker: raise WorkflowException( 'Requested workflow definition not found.') else: return default res = apply(wf.getInfoFor, (ob, name, default) + args, kw) if res is _marker: raise WorkflowException('Could not get info: %s' % name) return res