[Zope] Invalidating a session, creating a new

Sune Broendum Woeller zope at syntetisk.dk
Sat Oct 23 13:37:34 EDT 2004


Hi all,

In the zope book, sessions chapter, is written:

"Manually Invalidating A Session Data Object

Developers can manually invalidate a session data object. When a session
data object is invalidated, it will be flushed from the system, and will not
be returned by subsequent references to REQUEST.SESSION or getSessionData().
"

and :

"...subsequent references to REQUEST.SESSION in this same request will
return a new session data object."

I would like to be able to invalidate the session object, and then create a
new session with a new key, to be accessed in the next request.

But I find that when invalidating a session data object, I can *still*
access the old session data in subsequent references to REQUEST.SESSION, in
the same request that is. I do not get a new session data object, as I
should according to the zope book. And therefore I can not reference the new
keys I create in the following requests.

Has anyone got a solution for this problem ?

It seems the invalidation goes on "between" requests.

Is this an error with the sessioning machinery or in the zope book ?

Below there are three test scripts, that shows what is going on.

greetings,
Sune B. Woeller




file test1.py:
******
s = context.REQUEST.SESSION

s['mykey']='myvalue'

print "Page 1, add a key to session.<br />"
print "session : <br />"
print s
print "<br /><br />"
print '<a href ="test2">Page 2, invalidate session and add a new key</a><br
/>'
print '<a href ="test3">Page 3, show session</a><br />'

return printed

*****

file test2.py:
*****
s = context.REQUEST.SESSION

print "Page 2, invalidate session and add a new key.<br />"

s.invalidate()

s['mySecondKey']='mySecondValue'
print "session after invalidate: <br />"
print s

print "<br /><br />"
print '<a href ="test1">Page 1, add a key to session</a><br />'
print '<a href ="test3">Page 3, show session</a><br />'

return printed

*****

file test3.py:
*****
s = context.REQUEST.SESSION
print "Page 3, show session<br />"
print "session : <br />"
print s

print "<br /><br />"
print '<a href ="test1">Page 1</a><br />'
print '<a href ="test2">Page 2</a><br />'

return printed





More information about the Zope mailing list