Each Pyramid application has an associated .ini file that contains its settings. For example, a default might look like:
[app:main]
use = egg:MyProject
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
...
I am wondering if it is possible to add your own configuration values in there, and read them at run-time (mostly from a view callable). For instance, I might want to have
[app:main]
blog.title = "Custom blog name"
blog.comments_enabled = true
...
Or is it better to have a separate .ini file and parse it during startup?
Sure you can.
In your entry point function (
main(global_config, **settings)
in__init__.py
in most cases), your config is accessible in thesettings
variable.For example, in your
.ini
:In your
__init__.py
:According to the latest Pyramid docs, you can access the settings in a view function via
request.registry.settings
. Also, as far as I know, it will be in event subscribers viaevent.request.registry.settings
.Regarding your question about using another file, I'm pretty sure it's good practice to put all your config in the regular init file, using dotted notation like you did.