Looking for an eventhandler just before the response goes out

Hi,

I am looking for some event handler or hook which allows me to inspect the response from Plone to the browser just before it goes out. I am mainly interested in the "primary" responses which usually have the content type "text/html" but that's not a must.

I already know this sorcery:

from Products.CMFCore.interfaces import ISiteRoot
from zope.traversing.interfaces import IBeforeTraverseEvent

def hookRequest(site, event):
    request = event.request

    # Do something

gsm = zope.component.getGlobalSiteManager()
gsm.registerHandler(hookRequest, (ISiteRoot, IBeforeTraverseEvent))

But I did not find the possibility to hook into the response process. I wanna be able to see what the browser sees. I tried the following instead of IBeforeTraverseEvent but it not fire a single time.

from zope.publisher.interfaces import IEndRequestEvent

Am I thinking wrong? Can someone explain what I have to do? Thanks!

Perhaps one of these?

BaseRequest.py:            notify(EndRequestEvent(None, self))
HTTPResponse.py:            notify(pubevents.PubBeforeStreaming(self))
HTTPResponse.py:            notify(pubevents.PubBeforeStreaming(self))

WSGIPublisher.py:        notify(pubevents.PubStart(request))
WSGIPublisher.py:        notify(pubevents.PubBeforeCommit(request))
WSGIPublisher.py:        notify(pubevents.PubSuccess(request))
WSGIPublisher.py:            notify(pubevents.PubBeforeAbort(request, exc_info, retry))
WSGIPublisher.py:            notify(pubevents.PubFailure(request, exc_info, retry))
WSGIPublisher.py:    notify(pubevents.PubAfterTraversal(request))

Thanks. I will give it a try. Do I register them in the same way at ISiteRoot?

Perhaps look into haufe.requestmonitoring, in particular this here

1 Like