Robert Jean wrote at 2003-7-21 14:47 -0700:
I was trying the following script given in the Zope Book 2.6 (I am running Zope 2.6 on Windows):
## Script (Python) "sessionTest" secs_per_day=24*60*60 session=context.REQUEST.SESSION if session.has_key('last view'): # The script has been viewed before, since the 'last view' # has been previously set in the session. then=session['last view'] now=context.ZopeTime() session['last view']=now # reset last view to now return 'Seconds since last view %.2f' % ((now - then) * secs_per_day) # The script hasn't been viewed before, since there's no 'last # view' in the session data. session['last view']=context.ZopeTime() return 'This is your first view'
I get the following error:
Error Type: KeyError Error Value: SESSION
Your script above should not raise this exception. Did you check the traceback that the exception was really raised in the above script?
... Also, cookies are enabled. They are displayed when I do <dtml-var REQUEST>, but this snippet prints "not set" despite the fact that "foo" shows up among the cookies in DTML:
if container.REQUEST.RESPONSE.cookies.has_key('foo'):
You should drop the ".RESPONSE"! "cookies" is a "REQUEST" attribute. Dieter