[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Dynamic Content with DTML
nobody@nowhere.com
nobody@nowhere.com
Tue, 27 Aug 2002 00:12:10 -0400
A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/DTML.stx#2-90
---------------
Just for completeness sake, here's an implementation of the
*hasVisitedZoo* method as a Python-based Script::
## Script(Python) "hasVisitedZoo"
##parameters=REQUEST, RESPONSE
##
"""
Returns true if the user has previously visited
the Zoo. Uses cookies to keep track of zoo visits.
"""
if REQUEST.has_key('zooVisitCookie'):
return 1
else:
RESPONSE.setCookie('zooVisitCookie', '1')
return 0
% Anonymous User - Apr. 20, 2002 2:50 pm:
I think this needs to be updated. I did get this to work though:
## Script (Python) "hasVisitedZoo"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=hasVisitedZoo
##
"""
Returns true if the user has previously visited
the zoo. Uses cookies to keep track of zoo visits.
"""
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE = request.RESPONSE
if request.has_key('zooVisitCookie'):
return 1
else:
RESPONSE.setCookie('zooVisitCookie', '1')
return 0
% krump - Aug. 27, 2002 12:12 am:
Cutting and pasting seems to work so long as it is pasted into a Python script.