[Zope] Help with Page Counter (Python script), please
Uwe Schuerkamp
uwe.schuerkamp@nionex.net
Tue, 23 Apr 2002 09:44:12 +0200
Hi folks,
please bear with me for now, I am an all-out Zope/Python newbie and
only recently converted from Perl/CGI development ;-)
I'm trying to implement a simple page request counter by checking for
a property named "requestCount" in a DTML method, adding the property
if not found, incrementing it otherwise and returning the new value.
I'm using the following python script:
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE = request.RESPONSE
o = container.index_html
if (o.hasProperty("requestCount")):
print "request count property found, incrementing"
count = o.getProperty("requestCount")
o.manage_changeProperties(requestCount=count+1)
return o.getProperty("requestCount")
else:
print "request count property NOT found, incrementing"
o.manage_addProperty("requestCount", 1, "int")
return o.getProperty("requestCount")
this script lives in the top level of my Zope installation.
When I try to get a hit counter by including the script output as a
DTML-var like this:
<dtml-var incRequestCount>
in any subfolder the property of the Zope root folder is incremented
(where the Python script lives), but not the container of the current
object / container / folder whatever.
Say I have two index_html methods in subfolders, each using the
<dtml-var incRequestcount>
statement, there is only *one* counter associated with those methods
instead of two which get incremted separately.
Sorry for any confusion, I hope I have made myself clear!
Cheers & thanks in advance for any help / slaps on the forehead,
uwe
--
Uwe Schuerkamp Tel: +49 (0)5241 / 80 10 66, FAX: - / 6 23 38
Uwe.Schuerkamp@nionex.net Nionex GmbH, IWN5 (http://www.nionex.de/)
GnuPG KeyID: 5887047D Avenwedder Str. 55, 33311 Guetersloh
GnuPG Fingerprint: 2E 13 20 22 9A 3F 63 7F 67 6F E9 B1 A8 36 A4 61