Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share Pyramid configuration with a CLI script

Tags:

python

pyramid

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.

like image 213
gakhov Avatar asked Jul 22 '26 04:07

gakhov


1 Answers

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')
like image 80
Michael Merickel Avatar answered Jul 23 '26 19:07

Michael Merickel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!