diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2013-08-08 11:31:10 -0400 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2013-08-08 11:31:10 -0400 |
commit | 38c64ff3518470ff668a06725abb4d2f2d5ab7ba (patch) | |
tree | eb404b3ebac300a290a7e91df7873e1f3235e5ac | |
parent | 0629489d95b80a2e86ad0bddd59161158b62da4b (diff) | |
download | pecan-38c64ff3518470ff668a06725abb4d2f2d5ab7ba.tar.gz |
Clarify the __force_dict__ configuration directive.
-rw-r--r-- | docs/source/configuration.rst | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index f578ab4..ea4d29d 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -177,3 +177,27 @@ if you need to prefix the keys in the returned dictionary. Config({'app': Config({'errors': {}, 'template_path': '', 'static_root': 'public', [...] >>> conf.as_dict('prefixed_') {'prefixed_app': {'prefixed_errors': {}, 'prefixed_template_path': '', 'prefixed_static_root': 'prefixed_public', [...] + + +Dotted Keys and Native Dictionaries +----------------------------------- + +Sometimes you want to specify a configuration option that includes dotted keys. +This is especially common when configuring Python logging. By passing +a special key, ``__force_dict__``, individual configuration blocks can be +treated as native dictionaries. + +:: + + logging = { + 'loggers': { + 'root': {'level': 'INFO', 'handlers': ['console']}, + 'sqlalchemy.engine': {'level': 'INFO', 'handlers': ['console']}, + '__force_dict__': True + } + } + + from myapp import conf + assert isinstance(conf.logging.loggers, dict) + assert isinstance(conf.logging.loggers['root'], dict) + assert isinstance(conf.logging.loggers['sqlalchemy.engine'], dict) |