[Twisted-Python] Revisiting sessions

Edmund Dengler edmundd at eSentire.com
Sat Aug 9 17:09:04 EDT 2003


Just tried to get a session to apply to the entire website (rather than to
one subdirectory).

So, tried the following code:

========================================

from twisted.internet import reactor
from twisted.web import static, server
from twisted.web.woven import guard

sessWrapped = static.Data("you should never see this", "text/plain")
swChild = static.Data("NO", "text/plain")
sessWrapped.putChild("yyy", swChild)
swrap = guard.SessionWrapper(sessWrapped)

da = static.Data("you should never see this", "text/plain")
# da.putChild("", static.Data("The great void at the top", "text/plain"))
da.putChild("", swrap)

site = server.Site(da)
reactor.listenTCP(8080, site)
reactor.run()

============================

If I put the static.Data(), rather than the swrap as the Child, I get "The
great void at the top". If I try to use swrap to generate a session key, I
get:

lynx http://localhost:8080
==> redirects to http://localhost:8080//
==> Which returns a "No such child resource"

lynx http://localhost:8080/yyy
==> Which returns a "No such child resource"

lynx http://localhost:8080/session-init/yyy
==> Which returns a "No such child resource"

So, it seems that I cannot use the session at the top (at least the way I
think it works). What am I doing wrong?

Thanks!
Ed






More information about the Twisted-Python mailing list