Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: CMF

Workflow state change event

 

 

Zope cmf RSS feed   Index | Next | Previous | View Threaded


tim.terlegard at valentinewebsystems

May 15, 2008, 4:57 AM

Post #1 of 4 (337 views)
Permalink
Workflow state change event

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.

I would like it look like this:

def _invokeWithNotification(self, wfs, ob, action, func, args, kw):
...
if reindex:
self._reindexWorkflowVariables(ob)
for w in wfs:
w.notifySuccess(ob, action, res)
notify(ActionSucceededEvent(ob, w, action, res))
return res

Or do people have use cases where the current logic is better?

/Tim
_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


optilude at gmx

May 15, 2008, 1:31 PM

Post #2 of 4 (317 views)
Permalink
Re: Workflow state change event [In reply to]

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.

Martin

--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


tim.terlegard at valentinewebsystems

May 16, 2008, 3:56 AM

Post #3 of 4 (311 views)
Permalink
Re: Re: Workflow state change event [In reply to]

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.

/Tim_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests


l at lrowe

May 16, 2008, 8:34 AM

Post #4 of 4 (309 views)
Permalink
Re: Workflow state change event [In reply to]

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

_______________________________________________
Zope-CMF maillist - Zope-CMF[at]lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests

Zope cmf RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.