[Twisted-web] Re: Newbie help on session data

Nicola Larosa nico at tekNico.net
Mon Jun 14 02:18:45 MDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> I am working on an internal database app
> served by twisted.web.  I need help on
> how to attach data to sessions.  Point
> me to any examples to look at.

You can do this without adapters. Look at the Session class in the
twisted/web/server.py file. In the class __init__ (line #400 in v.1.2.0)
there's this cute "sessionNamespaces" empty dict attribute that is not
referenced anywhere else in the Twisted code. Put this somewhere:

sessNS = request.getSession().sessionNamespaces
sessNS['someKey'] = something

and somewhere else:

sessNS = request.getSession().sessionNamespaces
something = sessNS['someKey']

Works like a charm. :^)

Now, if we could change those session timeouts, that would be something. ;^)


- --
Nicola Larosa - nico at tekNico.net

"Pressure is something that you choose to embrace in your life or not.
Pressure is drama, and doesn't really interest me in my everyday life."
 -- Julia Roberts


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAzV9kXv0hgDImBm4RAs/2AKCuS4Fg0PFbPj2K5uA3NQ//ZcCL6gCgmdfQ
yKQBafV8Hq7vFGgTize/tew=
=I1+s
-----END PGP SIGNATURE-----




More information about the Twisted-web mailing list