gakhov
gakhov

Reputation: 1971

Share Pyramid configuration with a CLI script

I have a standalone python CLI script (which usually i run with crontab) which I want to integrate into my Pyramid app in terms of accessing Pyramid app configuration and load environment.

When i used Django that could be done like this:

from django.core.management import setup_environ
from myapp import settings

setup_environ(settings)

What is the best practice to do the same stuff with Pyramid? Thank you.

Upvotes: 3

Views: 397

Answers (1)

Michael Merickel
Michael Merickel

Reputation: 23331

Pyramid provides the bootstrap api to do this. Docs attached below.

http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/commandline.html#writing-a-script

from pyramid.paster import bootstrap
env = bootstrap('/path/to/my/development.ini#another')

Upvotes: 4

Related Questions