Skip to content

Instantly share code, notes, and snippets.

@wylee
Created January 17, 2013 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wylee/4559038 to your computer and use it in GitHub Desktop.
Save wylee/4559038 to your computer and use it in GitHub Desktop.
Accessing INI configuration from within Pyramid
# development.ini
[server:main]
use = egg:waitress
[app:main]
use = call:myproject:main
[app:mysettings]
use = call:myproject:noop
a = 1
b = 2
# __init__.py
from pyramid.paster import get_appsettings
def main(global_config, **settings):
config_file = global_config['__file__']
my_settings = get_appsettings(config_file, 'mysettings')
# my_settings == {
# '__file__': '/Users/wyatt/Projects/MyProject/development.ini',
# 'here': '/Users/wyatt/Projects/MyProject',
# 'a': '1',
# 'b': '2',
# }
# The usual Pyramid stuff here...
noop = lambda global_config, **settings: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment