Created
January 17, 2013 19:46
-
-
Save wylee/4559038 to your computer and use it in GitHub Desktop.
Accessing INI configuration from within Pyramid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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