[Zope-CMF] Re: Workflow state change event

Laurence Rowe l at lrowe.co.uk
Fri May 16 11:34:01 EDT 2008


Tim Terlegård wrote:
> On May 15, 2008, at 10:31 PM, Martin Aspeli wrote:
> 
>> Tim Terlegård wrote:
>>> I was wondering if it perhaps would make sense to move the
>>> ActionSucceededEvent notification after the reindexing of the
>>> workflow status has been done?
>>> doActionFor(...) calls _invokeWithNotification(...) and the bottom
>>> of that method looks like this:
>>> def _invokeWithNotification(self, wfs, ob, action, func, args, kw):
>>>         ...
>>>         for w in wfs:
>>>             w.notifySuccess(ob, action, res)
>>>             notify(ActionSucceededEvent(ob, w, action, res))
>>>         if reindex:
>>>             self._reindexWorkflowVariables(ob)
>>>         return res
>>> In an event handler I would like to use the catalog and search for  
>>> published
>>> objects, but it's not possible because the catalog is updated after  
>>> the event
>>> handler is triggered.
>>
>> That shouldn't matter, though - you get the object as part of the 
>> event, no need to search for it.
> 
> 
> The grandparent of the object is doing a catalog search, so the object that
> currently got a new workflow state isn't found.
> 
> The whole use case:
> 
> siteroot
>    - folderA
>       - docB
> 
> I have an 'is_empty' index that is based on catalog searches. When folderA
> doesn't contain any published objects it's considered empty. When workflow
> is changed on object docB, going from visible to published, I need to 
> reindex
> the object, and also the parent and the grandparent etc.  So when the state
> change event handler for docB calls 
> folderA.reindexObject(idxs=['is_empty'])
> it will not find docB because the catalog does not reflect the state 
> change yet.

Reindex the object in your event handler where you reindex the parents.

Laurence



More information about the Zope-CMF mailing list