[Web-SIG] Session events

Robert Brewer fumanchu at aminus.org
Mon Oct 5 17:24:56 CEST 2009


Alastair "Bell" Turner wrote:
> I've been looking through the range of choices for Python web
> [application] frameworks/libraries (Just to have all the bases
> covered) for a new build project and standardisation of some small
> utilities. There's one feature that I'm not finding and was just
> wanting to check on before considering the joys of rolling my own: I'm
> not finding any support for user session events, I'm particularly
> interested in being able to register a handler on session expiry or
> cleanup. I've mainly been looking at the lighter weight frameworks
> since my requirement for the new build is mainly aggregate and list
> operations, so the least suitable load for ORMs.

I hope, for your own sanity, that by "rolling my own" you mean "my own
session extension", not "my own web framework." ;)

> Have I missed the feature session event somewhere?

You haven't missed it in CherryPy because we actually took it out a few
years ago on purpose--it was a request rare enough to warrant favoring
simplicity of the code base over feature creep. These days, the standard
approach in CP 3.x is to subclass cherrypy.lib.sessions.FileSession (or
one of the others), and add your own calls where you want them, then
just stuff your new class into the sessions module via
"cherrypy.lib.sessions.MyFileSession = MyFileSession" (and the config
system will automatically pick it up).


Robert Brewer
fumanchu at aminus.org



More information about the Web-SIG mailing list