[Cubicweb] Workflows and Hooks
nicolas.chauvat at logilab.fr
Fri Aug 3 23:22:23 CEST 2012
On Wed, Aug 01, 2012 at 03:42:55PM +0200, Sylvain Thénault wrote:
> On 01 août 11:37, Aurélien Campéas wrote:
> > Le 01/08/2012 11:17, Stéphane Bugat a écrit :
> > >I'm trying to capture the moment when a workflow changes its status to perform a relation creation.
> > That leaves at least another way using wf_info_for (as an exercice ;-)
> And this is the way I promote, because that's the place where you've
> all the information you may need (from which state, to which state, using
> which transition, etc). So you've to catch creation of TrInfo entities, and
> there is a dedicated selector to help here :
> class TransitionFiredHook(hook.Hook):
> __regid__ = 'myhook'
> __select__ = hook.Hook.__select__ & on_fire_transition('SearchedEntityType', 'transition name')
> events = ('after_add_entity',)
> def __call__(self):
> print self.entity # the TrInfo entity
> print self.entity.for_entity # the SearchEntityType entity
I added a ticket to document this common usecase in the cubicweb book.
logilab.fr - services en informatique scientifique et gestion de connaissances
More information about the Cubicweb