[Zope-dev] __after_publishing_traverse__
Shane Hathaway
shane@zope.com
Mon, 15 Apr 2002 11:16:25 -0400
Ivo van der Wijk wrote:
> Hi All,
>
> I would like to do some bookkeeping *after* an object has been published,
> i.e. imagine a request is done for:
>
> /a/b/c/d
>
> 'b' is the (folderish) object that does the accounting, 'd' is the object
> to be published. I would like 'b' to examine the RESPONSE after publishing.
>
> I know there's a __before_publishing_traverse__, however, this is not what
> I want.
>
> Does someone know a way to implement this cleanly? I.e. without monkeypatching
> 'd' (which can be any kind of zope object)?
REQUEST._hold() is designed for this purpose. _hold() accepts an object
which will be deleted when the request is finished. Add an object with
a __del__() method that calls your application logic. In fact, this is
the mechanism Zope uses to make sure the database connection gets
closed. (see ZODB/ZApplication.py.)
Shane