[Twisted-web] Nevow: How to use sessions?
mohamed at your-site.com
Tue Dec 14 09:28:48 MST 2004
--On Tuesday, December 14, 2004 8:01 AM -0800 Donovan Preston
<dp at ulaluma.com> wrote:
> On Dec 14, 2004, at 6:24 AM, Mohamed Lrhazi wrote:
>> Can someone give a helloworld example of how to store and retrieve
>> objects specific to a session ? maybe a counter example. The objects
>> would need to be destroyed automatically when the session expires.
> The object returned from ISession(ctx) is yours to do with as you please.
> If your application is the only application which will be running on the
> server, then you can get and set attributes on it to store whatever
> information you like:
> ISession(ctx).foo = 1
> then later...
> getattr(ISession(ctx), 'foo', None)
> Which is kind of a pain...
Thanks dp, that clarified it up for me.
Now, I see in the twisted api one could have a function called when the
session is about to be destroyed. can I easily, from nevow, register a
function to do some clean up after a session is over? say my object holds a
connection to a database or whatever and I would need to close it and
update it or something?
More information about the Twisted-web