hooks/workflow.py
branchstable
changeset 4719 aaed3f813ef8
parent 4644 021035b9a7ab
child 4835 13b0b96d7982
equal deleted inserted replaced
4718:3dc3ad02d091 4719:aaed3f813ef8
    11 
    11 
    12 from cubicweb import RepositoryError, ValidationError
    12 from cubicweb import RepositoryError, ValidationError
    13 from cubicweb.interfaces import IWorkflowable
    13 from cubicweb.interfaces import IWorkflowable
    14 from cubicweb.selectors import implements
    14 from cubicweb.selectors import implements
    15 from cubicweb.server import hook
    15 from cubicweb.server import hook
    16 from cubicweb.entities.wfobjs import WorkflowTransition
       
    17 
    16 
    18 
    17 
    19 def _change_state(session, x, oldstate, newstate):
    18 def _change_state(session, x, oldstate, newstate):
    20     nocheck = session.transaction_data.setdefault('skip-security', set())
    19     nocheck = session.transaction_data.setdefault('skip-security', set())
    21     nocheck.add((x, 'in_state', oldstate))
    20     nocheck.add((x, 'in_state', oldstate))
    50 
    49 
    51 class _FireAutotransitionOp(hook.Operation):
    50 class _FireAutotransitionOp(hook.Operation):
    52     """try to fire auto transition after state changes"""
    51     """try to fire auto transition after state changes"""
    53 
    52 
    54     def precommit_event(self):
    53     def precommit_event(self):
    55         session = self.session
       
    56         entity = self.entity
    54         entity = self.entity
    57         autotrs = list(entity.possible_transitions('auto'))
    55         autotrs = list(entity.possible_transitions('auto'))
    58         if autotrs:
    56         if autotrs:
    59             assert len(autotrs) == 1
    57             assert len(autotrs) == 1
    60             entity.fire_transition(autotrs[0])
    58             entity.fire_transition(autotrs[0])