In some cases (e.g. large OFS.File/Image responses), Zope 2 will use
response.write() to stream the response.
We have events that fire before and after a "regular" response is
returned, but none that allow us to set headers (caching headers, in
this case) before such a streaming response is calculated. The normal
events fire too late.
We'd therefore like to add a new event in the HTTPResponse class (in
ZServer, though I think it makes sense to add to the ZPublisher base
class version as well). It'd hook in something like this:
if not self._wrote:
# new event code
site = getSite()
request = getattr(site, 'REQUEST', None)
# continue as before...
(I couldn't find a better way to get hold of the request from a method
in the response, without adding a dependency on five.globalrequest,
which I assume is not desirable).
Any objections? We need this in Zope 2.12, though I'll obviously merge
to trunk, too.
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -