equal
deleted
inserted
replaced
406 'WF workflow_of ET', {'x': self.eid}, 'x') |
406 'WF workflow_of ET', {'x': self.eid}, 'x') |
407 if len(wfrset) == 1: |
407 if len(wfrset) == 1: |
408 return wfrset.get_entity(0, 0) |
408 return wfrset.get_entity(0, 0) |
409 if len(wfrset) > 1: |
409 if len(wfrset) > 1: |
410 for wf in wfrset.entities(): |
410 for wf in wfrset.entities(): |
411 if wf.is_default_workflow_of(self.id): |
411 if wf.is_default_workflow_of(self.__regid__): |
412 return wf |
412 return wf |
413 self.warning("can't find default workflow for %s", self.id) |
413 self.warning("can't find default workflow for %s", self.__regid__) |
414 else: |
414 else: |
415 self.warning("can't find any workflow for %s", self.id) |
415 self.warning("can't find any workflow for %s", self.__regid__) |
416 return None |
416 return None |
417 |
417 |
418 def possible_transitions(self): |
418 def possible_transitions(self): |
419 """generates transition that MAY be fired for the given entity, |
419 """generates transition that MAY be fired for the given entity, |
420 expected to be in this state |
420 expected to be in this state |
450 """change the entity's state by firing transition of the given name in |
450 """change the entity's state by firing transition of the given name in |
451 entity's workflow |
451 entity's workflow |
452 """ |
452 """ |
453 assert self.current_workflow |
453 assert self.current_workflow |
454 tr = self.current_workflow.transition_by_name(trname) |
454 tr = self.current_workflow.transition_by_name(trname) |
455 assert tr is not None, 'not a %s transition: %s' % (self.id, trname) |
455 assert tr is not None, 'not a %s transition: %s' % (self.__regid__, trname) |
456 return self._add_trinfo(comment, commentformat, tr.eid) |
456 return self._add_trinfo(comment, commentformat, tr.eid) |
457 |
457 |
458 def change_state(self, statename, comment=None, commentformat=None, tr=None): |
458 def change_state(self, statename, comment=None, commentformat=None, tr=None): |
459 """change the entity's state to the given state (name or entity) in |
459 """change the entity's state to the given state (name or entity) in |
460 entity's workflow. This method should only by used by manager to fix an |
460 entity's workflow. This method should only by used by manager to fix an |
469 warn('give a state name') |
469 warn('give a state name') |
470 state = self.current_workflow.state_by_eid(statename) |
470 state = self.current_workflow.state_by_eid(statename) |
471 else: |
471 else: |
472 state = self.current_workflow.state_by_name(statename) |
472 state = self.current_workflow.state_by_name(statename) |
473 if state is None: |
473 if state is None: |
474 raise WorkflowException('not a %s state: %s' % (self.id, |
474 raise WorkflowException('not a %s state: %s' % (self.__regid__, |
475 statename)) |
475 statename)) |
476 stateeid = state.eid |
476 stateeid = state.eid |
477 # XXX try to find matching transition? |
477 # XXX try to find matching transition? |
478 return self._add_trinfo(comment, commentformat, tr and tr.eid, stateeid) |
478 return self._add_trinfo(comment, commentformat, tr and tr.eid, stateeid) |
479 |
479 |