entities/wfobjs.py
branch3.5
changeset 2945 f0ab83510477
parent 2944 3bd49b70f7f9
child 2946 957fd4b276e2
equal deleted inserted replaced
2944:3bd49b70f7f9 2945:f0ab83510477
    78 
    78 
    79     def add_state(self, name, initial=False, **kwargs):
    79     def add_state(self, name, initial=False, **kwargs):
    80         """method to ease workflow definition: add a state for one or more
    80         """method to ease workflow definition: add a state for one or more
    81         entity type(s)
    81         entity type(s)
    82         """
    82         """
    83         state = self.req.create_entity('State', name=name, **kwargs)
    83         state = self.req.create_entity('State', name=unicode(name), **kwargs)
    84         self.req.execute('SET S state_of WF WHERE S eid %(s)s, WF eid %(wf)s',
    84         self.req.execute('SET S state_of WF WHERE S eid %(s)s, WF eid %(wf)s',
    85                          {'s': state.eid, 'wf': self.eid}, ('s', 'wf'))
    85                          {'s': state.eid, 'wf': self.eid}, ('s', 'wf'))
    86         if initial:
    86         if initial:
    87             assert not self.initial
    87             assert not self.initial
    88             self.req.execute('SET WF initial_state S '
    88             self.req.execute('SET WF initial_state S '
    93     def add_transition(self, name, fromstates, tostate,
    93     def add_transition(self, name, fromstates, tostate,
    94                        requiredgroups=(), conditions=(), **kwargs):
    94                        requiredgroups=(), conditions=(), **kwargs):
    95         """method to ease workflow definition: add a transition for one or more
    95         """method to ease workflow definition: add a transition for one or more
    96         entity type(s), from one or more state and to a single state
    96         entity type(s), from one or more state and to a single state
    97         """
    97         """
    98         tr = self.req.create_entity('Transition', name=name, **kwargs)
    98         tr = self.req.create_entity('Transition', name=unicode(name), **kwargs)
    99         self.req.execute('SET T transition_of WF '
    99         self.req.execute('SET T transition_of WF '
   100                          'WHERE T eid %(t)s, WF eid %(wf)s',
   100                          'WHERE T eid %(t)s, WF eid %(wf)s',
   101                          {'t': tr.eid, 'wf': self.eid}, ('t', 'wf'))
   101                          {'t': tr.eid, 'wf': self.eid}, ('t', 'wf'))
   102         for state in fromstates:
   102         for state in fromstates:
   103             if hasattr(state, 'eid'):
   103             if hasattr(state, 'eid'):