I think there is a cleaner way. No need to modify the applications/
admin/cron/expire_sessions.py whenever you add or remove your apps.
You just put this line into each of applications/your_app/cron/crontab

    10  2       *       *       *       root 
**applications/admin/cron/expire_sessions.py

The point here is that, you only need to invoke the built-in admin/
cron/expire_sessions.py, because it can already work on caller-app's
folder.

@Massimo:
And I just don't see any reason why this line does not go into
scaffold app.

@Annet:
Sorry, but what do you mean "emil"?


On May19, 6:39pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> You can but you can also modify expire_sessions.py
>
> EXPIRATION_MINUTES=60
> import os, time, stat
> for app in ['admin','init','examples','welcome']: # add yours
>     path=os.path.join(request.folder,'..',app,'sessions')
>     if not os.path.exists(path):
>        os.mkdir(path)
>     now=time.time()
>     for file in os.listdir(path):
>         filename=os.path.join(path,file)
>         t=os.stat(filename)[stat.ST_MTIME]
>         if os.path.isfile(filename) and now-t>EXPIRATION_MINUTES*60 \
>           and file.startswith(('1','2','3','4','5','6','7','8','9')):
>           os.unlink(filename)
>
> so that one expire_sessions.py does it for all your apps.
> On May 19, 5:21 am, annet <annet.verm...@gmail.com> wrote:
>
>
>
> > Massimo,
>
> > Emil just tried running the following command on my account:
>
> > python2.5 /home/fitwise/webapps/customweb2py/web2py/web2py.py  -S
> > admin -R applications/admin/cron/expire_sessions.py
>
> > This was successfully executed, and the output was:
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2010
> > Version 1.76.5 (2010-03-11 15:19:08)
> > Database drivers available: SQLite3, MySQL, PostgreSQL
>
> > I verified that this actually cleaned up my sessions. It did in admin,
> > not in init, b2b etc. Would it be possible to copy the
> > expire_sessions.py to every single application's cron directory and
> > set this command as a cron by editing my crontab (crontab -e):
>
> > 10 * * * * /usr/local/bin/python2.5 /home/fitwise/webapps/customweb2py/
> > web2py/web2py.py  -S init -R applications/init/cron/expire_sessions.py
>
> > According to Emil:
>
> > Applications do not really have crontabs. They may have some built-in
> > feature which makes them work similar to crontab, but it is a
> > completely separate system than your "real" crontab (the one you see
> > when you runt 'crontab -l').
>
> > By the way, the Web2py installation that I have is running behind
> > Apache + mod_wsgi.
>
> > Kind regards,
>
> > Annet.

Reply via email to