I have a pyramid application using a paster ini file, which is hosted via uwsgi. I want to host different instances (i.e. development, staging, production), ideally without having to touch the config file at all. Obviously different instances need different settings. My approach was something like:
[app:base]
sqlalchemy.url = some/connection/string/%(instance)s
[app:development]
instance = development
[app:production]
instance = production
That does not work, because instance
is not yet defined, when sqlalchemy.url
is defined. I tried to inject instance
somehow from the outside, but without success. I'm not able to access any environment variables. I also tried to pass values via uwsgi_param
from Nginx, but could not get it to work.
How do I organize paster ini files in a modular way, so that I do not have to duplicate settings?
You can use the "config:" URL to include settings from another file.
In "shared.ini"
In "development.ini"
In "production.ini"
Here's some real world code that uses the pattern:
https://github.com/Pylons/sdidev/blob/master/etc/development.ini