Hello, 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 My session_data_manager has the following (default) setting: Place SESSION in REQUEST object as: SESSION 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'): print "set" else: print "not set" Any idea of what may be wrong? Thanks, Robert __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
On ma, 21.07.2003 at 14:47 -0700, Robert Jean wrote:
## Script (Python) "sessionTest" [...]
I get the following error:
Error Type: KeyError Error Value: SESSION
This script works fine with my Zope 2.6.0. -- paavo. "joskus voi tää meno käydä ahdistavaksi kun on täällä muodostunut tavaksi muuttaa jokaisen elämän arvo rahaksi"
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
participants (3)
-
Dieter Maurer -
Paavo Parkkinen -
Robert Jean