[Zope3-Users] Re: IEndRequestEvent question

Philipp von Weitershausen philipp at weitershausen.de
Tue Jun 6 07:32:38 EDT 2006


Thierry FLORAC wrote:
> 
>   Hi,
> 
> I'd like to ask several questions about "IEndRequestEvent", like :
> - when is this event actually fired ?

When everything else with a request has been done.

> - what can be done exactly after this event is fired (still query
> components, update database...) ?

You can always query global components. The local component registry
will be reset using a subscriber to IEndRequestEvent, so you can't be
sure to get those in a subscriber to this event because you don't know
whether it's executed before or after the other one.

You could make modifications to the database, HOWEVER: the original
transaction has already been committed (or aborted). That means a) any
error you raise in this subscriber won't revert changes from this
request and b) you'll have to commit your changes manually in anohter
transaction (import transaction; transaction.commit()).

> - if possible, are modifications done after this event integrated into
> the main transaction ?

Nope (see above).

You can change all of this behaviour by providing your own publication.
The publication is responsible for doing all framework-related things
around the publication process (make a request, start interactions and
transactions, fire events, etc.). Have a look at zope.app.publication
(zopepublication.py in particular).

> My goal is to use request annotations to reference several objects that
> should be treated after the main request process is done, and then to
> subscribe to this event to fire these final modifications (so that, for
> example, "IObjectModifiedEvent" is not fired too many times). Is it the
> good approach ?

Why are you concerned about IObjectModifiedEvent being fired too many times?

Philipp



More information about the Zope3-users mailing list