Access rule for Python Product
I need to run a function whenever my python product is published. This function will record the name os the user that viewed the object and the id of the object. If I was doing this all through the ZMI, I would create an access rule for each customer (folderish) object instance. However, I want this access rule built into my product. How would I do this? Thanks -- Chad Nantais Rednaxel Interactive
On Tue, Apr 15, 2003 at 08:06:22PM -0700, Chad Nantais wrote:
I need to run a function whenever my python product is published. This function will record the name os the user that viewed the object and the id of the object.
If I was doing this all through the ZMI, I would create an access rule for each customer (folderish) object instance. However, I want this access rule built into my product. How would I do this?
build it in to the view method of your class. Something like this (untested, and assuming you use zlog for the records) ... from zLOG import LOG from AccessControl import getSecurityManager class MyProduct(some_zopeish_base_class): ... index_html = None # tell the publisher to use __call__ for the view def __call__(self, client=None, REQUEST=None, RESPONSE=None, **kw) user = getSecurityManager().getUser() LOG('User %s viewed %s' % (user, self.getId()) ... -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's RANDY PROCTOLOGIST! (random hero from isometric.spaceninja.com)
Chad Nantais wrote at 2003-4-15 20:06 -0700:
If I was doing this all through the ZMI, I would create an access rule for each customer (folderish) object instance. However, I want this access rule built into my product. How would I do this?
Read something about the "__before_publishing_traverse__" hook. You find a bit in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> I expect, you will find more on Zope.org. Have a look at the "SiteAccess" source. It uses the hook above to implement access rules. Dieter
participants (3)
-
Chad Nantais -
Dieter Maurer -
Paul Winkler