selectors.py
branchstable
changeset 7529 2fdc310be7cd
parent 7452 7e8182a63559
child 7559 50122a47ce4f
equal deleted inserted replaced
7528:11659cbe5eea 7529:2fdc310be7cd
  1250                            ','.join(str(s) for s in self.expected))
  1250                            ','.join(str(s) for s in self.expected))
  1251 
  1251 
  1252 
  1252 
  1253 def on_fire_transition(etype, tr_name, from_state_name=None):
  1253 def on_fire_transition(etype, tr_name, from_state_name=None):
  1254     """Return 1 when entity of the type `etype` is going through transition of
  1254     """Return 1 when entity of the type `etype` is going through transition of
  1255     the name `tr_name`. If `from_state_name` is specified, this selector will
  1255     the name `tr_name`.
  1256     also check the incoming state.
  1256     
       
  1257     If `from_state_name` is specified, this selector will also check the
       
  1258     incoming state.
  1257 
  1259 
  1258     You should use this selector on 'after_add_entity' hook, since it's actually
  1260     You should use this selector on 'after_add_entity' hook, since it's actually
  1259     looking for addition of `TrInfo` entities. Hence in the hook, `self.entity`
  1261     looking for addition of `TrInfo` entities. Hence in the hook, `self.entity`
  1260     will reference the matching `TrInfo` entity, allowing to get all the
  1262     will reference the matching `TrInfo` entity, allowing to get all the
  1261     transition details (including the entity to which is applied the transition
  1263     transition details (including the entity to which is applied the transition
  1262     but also its original state, transition, destination state, user...).  See
  1264     but also its original state, transition, destination state, user...).
  1263     :class:`cubicweb.entities.wfobjs.TrInfo` for more information.
  1265     
       
  1266     See :class:`cubicweb.entities.wfobjs.TrInfo` for more information.
  1264     """
  1267     """
  1265     def match_etype_and_transition(trinfo):
  1268     def match_etype_and_transition(trinfo):
  1266         # take care trinfo.transition is None when calling change_state
  1269         # take care trinfo.transition is None when calling change_state
  1267         return (trinfo.transition and trinfo.transition.name == tr_name
  1270         return (trinfo.transition and trinfo.transition.name == tr_name
  1268                 # is_instance() first two arguments are 'cls' (unused, so giving
  1271                 # is_instance() first two arguments are 'cls' (unused, so giving