How to use the common ini configuration (between development and production) in a pyramid?

I want to have a common configuration with settings that do not change in different environments (development and production). I know that I can configure the global settings.py file (for example, sql limits), but as far as I know, the pyramid requires certain parameters to be in the ini file at startup (for example, the path to the template directories).

Can I, and if so, how to do it in a pyramid?

+8
python pyramid configuration
source share
1 answer

There are several possible options without going beyond the PasteDeploy INI limits. However, first of all, realize the beauty of the INI file model - this is the basic ability to create several files with different settings / configurations. Yes, you should synchronize them, but these are just settings (without logic), so this should not be irresistible.

In any case, PasteDeploy supports the default partition , which is inherited by the [app:XXX] sections. Thus, you can post general settings there and have different sections [app:myapp-dev] and [app:myapp-prod] .

 # settings.ini [DEFAULT] foo = bar [app:myapp-dev] use = egg:myapp [app:myapp-prod] use = egg:myapp set foo = baz 

This can be started using

 env/bin/pserve -n myapp-dev settings.ini 

Another option is to use multiple configuration files.

 # myapp.ini [app:myapp-section] use = egg:myapp foo = bar # myapp-dev.ini [app:main] use = config:myapp.ini#myapp-section foo = baz # myapp-prod.ini [app:main] use = config:myapp.ini#myapp-section 

This can be started using

 env/bin/pserve myapp-prod.ini 

If you do not want to use PasteDeploy (ini files), you can do something in Python, but there are real advantages to a simple configuration of this configuration.

+16
source share

All Articles