Ejemplo n.º 1
0
 def set(self, value):
     self.annotations['dcworkflow_id'] = value
     if value is not None:
         wf = self._get_workflow()
         # reset workflow state to intial state of new workflow
         # XXX: Should we try to use an existing state when we switch back
         # to a workflow we had before?
         wf.notifyCreated(self.rel)
     # reindex for new state
     if IBidirectionalRelationshipIndex.providedBy(self.rel.__parent__):
         self.rel.__parent__.reindex(self.rel)
Ejemplo n.º 2
0
def deleteReferenceOnTargetDelete(rel, event):
    """deleted references related to the object"""
    if IBidirectionalRelationshipIndex.providedBy(rel.__parent__):
        index = rel.__parent__
    else:
        index = None
    if len(rel.targets) > 1:
        rel.targets.remove(event.target)
        if index is not None:
            index.reindex(rel)
    elif event.target in rel.targets and index is not None:
        index.remove(rel)
Ejemplo n.º 3
0
 def setContext(self, value):
     self.annotations['context'] = value
     if IBidirectionalRelationshipIndex.providedBy(self.rel.__parent__):
         self.rel.__parent__.reindex(self.rel)
Ejemplo n.º 4
0
 def set(self, value):
     self.annotations['wf_state_var'] = value
     # reindex for new state
     if IBidirectionalRelationshipIndex.providedBy(self.rel.__parent__):
         self.rel.__parent__.reindex(self.rel)
Ejemplo n.º 5
0
        wf.notifyBefore(self.rel, action)
        # notify(Blah)

        # XXX: no support for moving relationships during workflow for now
        try:
            res = wf.doActionFor(self.rel, action, comment, **kw)
        except ObjectDeleted, ex:
            res = ex.getResult()
        except:
            exc = sys.exc_info()
            wf.notifyException(self.rel, action, exc)
            #notify(Blah)
            raise
        wf.notifySuccess(self.rel, action, res)
        # Reindex (this should probably be triggered by an event)
        if IBidirectionalRelationshipIndex.providedBy(self.rel.__parent__):
            self.rel.__parent__.reindex(self.rel)
        #notify(Blah)
        return res

    def isActionAllowed(self, action):
        wf = self._get_workflow()
        return bool(wf.isActionSupported(self.rel, action))

    def getInfo(self, name, default=_marker, *args, **kw):
        wf = self._get_workflow()
        res = wf.getInfoFor(self.rel, name, default, *args, **kw)
        if res is _marker:
            raise WorkflowException('Could not get info: %s' % name)
        return res