On Mon, Feb 8, 2010 at 4:43 AM, Thomas G. Willis <[email protected]> wrote:
> I would write a custom paste command to do it, then schedule that as a
> cron job. There doesn't seem to be any reason to make that part of the
> request/response cycle.
>
> read up on this stuff http://pythonpaste.org/script/developer.html and
> maybe look at how pylons does it. 
> http://bitbucket.org/bbangert/pylons/src/tip/pylons/commands.py
>
> so you would have a command line similar to this.
> $ paste purge-old-files production.ini

There are a few other ways too.

$ paster request /cron/purge-old-files

$ python -m myapp.scripts.purge_old_files

Or spawn another thread in environment.py that does the job, sleeps
for a while, and does it again.

One difficulty in standalone utilities is getting the environment all
set up right so you have 'config', the model, etc.  You can look in
pylons.commands, websetup.py, and the test suite for ideas.  Perhaps
the easiest way is to load the application the way 'paster serve'
does:

# Assume sys.argv[1] == "development.ini"
import paste.deploy.loadwsgi as loadwsgi
app = loadwsgi.loadapp("config:" + sys.argv[1], relative_to=os,getcwd())


-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to