Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install plone.validatehook

How to install plone.validatehook

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install plone.validatehook
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0 Available View build log
Windows (64-bit)
1.0 Available View build log
Mac OS X (10.5+)
1.0 Available View build log
Linux (32-bit)
1.0 Available View build log
Linux (64-bit)
1.0 Available View build log
Web
 
License
ZPL
Lastest release
version 1.0 on Jan 5th, 2011

Introduction

This package provides a hook into Zope's ZPublisher that is run after the publisher has completed traversal and authentication, but before it tries to publish an object. This is practical for tasks such as tracking user activity.

Hooks use zope.event's event mechanism using the plone.validatehook.interfaces.IPostValidationEvent. This is based on the standard ObjectEvent form zope.component.

The IPostValidationEvent event has two attributes: user which is the currently authenticated user object and request, which is the current request object.

Keep in mind that even unauthenticated requests have a user object. If you only want to deal with 'normal' users make sure you ignore any instances of AccessControl.User.SpecialUser.

Example

As an example we will write a bit of code which logs the id of the current user and the path to the current code. This is the code for the event handler:

System Message: WARNING/2 (<string>, line 29)

Literal block expected; none found.

from zope.interface import Interface from zope.component import adapter from plone.validatehook.interfaces import IPostValidationEvent import logging

logger = logging.getLogger("LogRequest")

@adapter(Interface, IPostValidationEvent) def LogRequest(object, event): if getattr(object, "getPhysicalPath", None) is None: path="Unknown path" else: path="/".join(object.getPhysicalPath()

logger.info("Request from user '%s' for object %s" % event.user.getId(), path)

To use this code you need to register it in zcml:

<subscriber handler=".events.LogRequest" />

Changelog

1.0 - October 15, 2008
  • Move to svn.zope.org and relicense under ZPL.

System Message: WARNING/2 (<string>, line 62)

Bullet list ends without a blank line; unexpected unindent.

[wichert]

1.0rc1 - July 15, 2008
  • Initial release

System Message: WARNING/2 (<string>, line 69)

Bullet list ends without a blank line; unexpected unindent.

[wichert]

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.