Hi Anthony,
Thanks for your reply, I got the idea of the solution now.
> Finally, do you even need the "id" key, given that it is the same as the
> name of its parent object? Couldn't you just do:
>
> from gluon.storage import Storage
> id = request.args(0)
> session[id] = Storage()
> session[id].somekey = 'some value'
>
I think I can I'll give it a try.
In the book I read:
> If you are storing sessions on filesystems and you have lots of them,
the file system access may become a bottle-neck
I changed the expire_sessions.py file to clean up expired sessions, will it
clean up the sessions created the way above as well?
EXPIRATION_MINUTES=60
DIGITS=('0','1','2','3','4','5','6','7','8','9')
import os, time, stat, logging
for app in ['admin','init']: # add your apps
path=os.path.join(request.folder,'sessions')
if not os.path.exists(path):
os.mkdir(path)
now=time.time()
for filename in os.listdir(path):
fullpath=os.path.join(path,filename)
try:
if os.path.isfile(fullpath):
t=os.stat(fullpath)[stat.ST_MTIME]
if now-t>EXPIRATION_MINUTES*60 and
filename.startswith(DIGITS):
try:
os.unlink(fullpath)
except Exception,e:
logging.warn('failure to unlink %s: %s' %
(fullpath,e))
except Exception, e:
logging.warn('failure to stat %s: %s' % (fullpath,e))
Does it make a difference whether you store session in the sessions folder
or in a database?
Are there other ways to clean up these sessions?
Kind regards,
Annet.
--