4 messages in com.googlegroups.pylons-discussRe: Use Pylons environment from exter...
FromSent OnAttachments
Konstantin Alexandrov20 Nov 2007 19:50 
Ian Bicking20 Nov 2007 19:52 
Max Ischenko21 Nov 2007 04:21 
Ignacio Martin22 Nov 2007 04:51 
Subject:Re: Use Pylons environment from external Python script
From:Ignacio Martin (natx@public.gmane.org)
Date:11/22/2007 04:51:24 AM
List:com.googlegroups.pylons-discuss

I use this at the beggining of my python external script:

-------------- from paste.deploy import appconfig from pylons import config

sys.path.append('/absolute/path/myapp')

from myapp.config.environment import load_environment

filename = '/absolute/path/myapp/development.ini'

conf = appconfig('config:' + filename) load_environment(conf.global_conf, conf.local_conf)

from myapp import model ----------------

Replace myapp by your app name and it should work. Is there a more elegant way to do it ? This seemed to me like a sort of a hack ...

Nacho

2007/11/21, Max Ischenko <isch@public.gmane.org>:

On Nov 21, 2007 5:52 AM, Ian Bicking
<ianb@public.gmane.org> wrote:

Konstantin Alexandrov wrote:

Hello all. I need to use my Pylons project's environment (config, models etc) from external script launched by cron. How to do that?

If you use PasteScript trunk, you can do "paster request config.ini /cron", which runs a request to /cron.

If you are not using PasteScript trunk you can still use paster " paste.paster_command" extensions point. Quite verbose but it works.