[Cubicweb] Workflows and Hooks

Stéphane Bugat stephane.bugat at free.fr
Wed Aug 1 14:52:51 CEST 2012


> 
> sometimes I write such hooks like:
> 
> class FooHappens(Hook):
>      __regid__ = 'mycube.foo_happens'
>      events = ('after_add_relation',)
>      __select__ = (Hook.__select__ &
>                    match_rtype('in_state', frometypes=('Notif',)))
> 
>      def __call__(self):
>          state = self._cw.entity_from_eid(self.eidto)
>   	if state.name = 'foo':
>              ...

Worked well, great :-)

> State entities dont get updated on workflowable transitions (see
> cw/schemas/workflow.py for its structure & relations)... (They are
> mostly immutable entities, which used in conjunction with
> Transitions,
> describe a workflow.)

Clear now!

> >    2. Is there another way to do it?
> 
> That leaves at least another way using wf_info_for (as an exercice
> ;-)
> 

Later perhaps! First workaround is ok.

Many thanks

Stephane


More information about the Cubicweb mailing list