Zope 2 post-publication hook
Project description
Introduction
This package provides a hook into Zope’s ZPublisher that is run after the publisher has completed publication, but before the the transaction is commited and the response is returned to the requesting browser. This is practical for caching purposes: it is the ideal place to determine and insert caching headers into the response.
Hooks use zope.event’s event mechanism using the plone.validatehook.interfaces.IPostValidationEvent. This is based on the standard ObjectEvent from zope.component.
Example
As an example we will write a bit of code which logs the path of every published object. This is the code for the event handler:
from zope.interface import Interface from zope.component import adapter from plone.postpublicationhook.interfaces import IAfterPublicationEvent import logging logger = logging.getLogger("LogRequest") @adapter(Interface, IAfterPublicationEvent) def LogRequest(object, event): if getattr(object, "getPhysicalPath", None) is None: path="Unknown path" else: path="/".join(object.getPhysicalPath() logger.info("Request for object %s" % path)
To use this code you need to register it in zcml:
<subscriber handler=".events.LogRequest" />
Changelog
1.0rc1 - October 15, 2008
Initial release [wichert]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for plone.postpublicationhook-1.0rc1.zip
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28e92f866eccc8d658639305811c4c8af1a7d57b96a6dab4a49e8585a7e959b4 |
|
MD5 | 862f39d6f3fb0be3a01db42eb4e6cecd |
|
BLAKE2b-256 | 71f70915af15dea6042f92c63bd05938d6a1af6870dc60bb528f578a701f125d |