cubicweb/predicates.py
changeset 12542 85194bd49119
parent 12508 a8c1ea390400
child 12567 26744ad37953
equal deleted inserted replaced
12541:bbbccb0b3a66 12542:85194bd49119
  1074     def __str__(self):
  1074     def __str__(self):
  1075         return '%s(%s)' % (self.__class__.__name__,
  1075         return '%s(%s)' % (self.__class__.__name__,
  1076                            ','.join(str(s) for s in self.expected))
  1076                            ','.join(str(s) for s in self.expected))
  1077 
  1077 
  1078 
  1078 
  1079 def on_fire_transition(etype, tr_names, from_state_name=None):
  1079 def on_fire_transition(etype, tr_names):
  1080     """Return 1 when entity of the type `etype` is going through transition of
  1080     """Return 1 when entity of the type `etype` is going through transition of
  1081     a name included in `tr_names`.
  1081     a name included in `tr_names`.
  1082 
  1082 
  1083     You should use this predicate on 'after_add_entity' hook, since it's actually
  1083     You should use this predicate on 'after_add_entity' hook, since it's actually
  1084     looking for addition of `TrInfo` entities. Hence in the hook, `self.entity`
  1084     looking for addition of `TrInfo` entities. Hence in the hook, `self.entity`
  1086     transition details (including the entity to which is applied the transition
  1086     transition details (including the entity to which is applied the transition
  1087     but also its original state, transition, destination state, user...).
  1087     but also its original state, transition, destination state, user...).
  1088 
  1088 
  1089     See :class:`cubicweb.entities.wfobjs.TrInfo` for more information.
  1089     See :class:`cubicweb.entities.wfobjs.TrInfo` for more information.
  1090     """
  1090     """
  1091     if from_state_name is not None:
       
  1092         warn("on_fire_transition's from_state_name argument is unused", DeprecationWarning)
       
  1093     if isinstance(tr_names, string_types):
  1091     if isinstance(tr_names, string_types):
  1094         tr_names = set((tr_names,))
  1092         tr_names = set((tr_names,))
  1095     def match_etype_and_transition(trinfo):
  1093     def match_etype_and_transition(trinfo):
  1096         # take care trinfo.transition is None when calling change_state
  1094         # take care trinfo.transition is None when calling change_state
  1097         return (trinfo.transition and trinfo.transition.name in tr_names
  1095         return (trinfo.transition and trinfo.transition.name in tr_names