Session problem on upgrade to version 3

10 views
Skip to first unread message

Andrew Veitch

unread,
Apr 30, 2007, 7:42:42 PM4/30/07
to cherryp...@googlegroups.com
I've just done an upgrade to version 3 which is
looking really good so far.

I'm having a fairly urgent problem with the
on_delete_session hooking being missing.

Someone else seems to be having the same issue:
http://www.cherrypy.org/ticket/678

I'd like to know if this functionality has been
removed and if so any ideas for the best way of fixing
would be appreciated.

Thanks

Andy

Robert Brewer

unread,
Apr 30, 2007, 8:13:42 PM4/30/07
to cherryp...@googlegroups.com

It's been removed because 1) it's a rare need, and 2) where to do it
varies with the use case and storage type. Can you describe your use
case and storage type?

It's *somewhat* easy to add yourself:

from cherrypy.lib import sessions

class MySessionProvider(sessions.FileSession):
def delete(self):
do_custom_on_delete_stuff()
self._delete()

def clean_up(self):
do_custom_on_delete_stuff()
sessions.FileSession.clean_up(self)

cherrypy.lib.sessions.MySessionProvider = MySessionProvider
cherrypy.config.update({'tools.sessions.storage_type':
'MySessionProvider'})

...obviously your "do_custom_on_delete_stuff" method will have to be
expanded, or be done after the self._delete()/clean_up calls, or even
inside them if you need to know which entries are being deleted.


Robert Brewer
System Architect
Amor Ministries
fuma...@amor.org

Andrew Veitch

unread,
Apr 30, 2007, 8:26:27 PM4/30/07
to cherryp...@googlegroups.com
> It's been removed because 1) it's a rare need, and
> 2) where to do it varies with the use case and
storage type. Can you
> describe your use case and storage type?

I run a social networking site and I have an 'online'
boolean in the database. When users login it's set as
True and when they logout or the session expires it's
set as False.

I currently have nearly a 1,000 users showing as
logged in when it should be 200-300.

I used to use RAM storage but I switched to File
storage because it really annoyed users to be logged
off when I restarted the server.

Thanks for the code, it's very late where I am but
I'll look at this tomorrow.

It would be great if the documentation could be
updated to mention that this has been removed -
would've saved me a few hours.

Thanks

Andrew

Reply all
Reply to author
Forward
0 new messages