diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-01-06 23:28:18 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-01-06 23:28:18 +0000 |
| commit | 09b96402ddc9f6a64b6d71d3be3b2d32c32e59df (patch) | |
| tree | 0f8bcd8919d370831db83c6c0f9057e9a7b34967 | |
| parent | 9a385906465baa34ec5e63e3b8b0ab86e2f85f98 (diff) | |
| download | pyramid-09b96402ddc9f6a64b6d71d3be3b2d32c32e59df.tar.gz pyramid-09b96402ddc9f6a64b6d71d3be3b2d32c32e59df.tar.bz2 pyramid-09b96402ddc9f6a64b6d71d3be3b2d32c32e59df.zip | |
- The ``repoze.bfg.registry.get_options`` callable used to return only
framework-specific keys and values in the dictionary it returned.
It now returns all the keys and values in the dictionary it is
passed *plus* any framework-specific settings culled from the
environment. As a side effect, all PasteDeploy application-specific
config file settings are made available as attributes of the
``ISettings`` utility from within BFG.
| -rw-r--r-- | CHANGES.txt | 8 | ||||
| -rw-r--r-- | repoze/bfg/registry.py | 9 | ||||
| -rw-r--r-- | repoze/bfg/tests/test_registry.py | 5 |
3 files changed, 21 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 0133a32e4..2908fde04 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,14 @@ Features - Renamed the existing BFG paster template to ``bfg_starter``. Added another template showing default ZODB setup using ``repoze.zodbconn``. +- The ``repoze.bfg.registry.get_options`` callable used to return only + framework-specific keys and values in the dictionary it returned. + It now returns all the keys and values in the dictionary it is + passed *plus* any framework-specific settings culled from the + environment. As a side effect, all PasteDeploy application-specific + config file settings are made available as attributes of the + ``ISettings`` utility from within BFG. + 0.6.1 (2009-01-06) ================== diff --git a/repoze/bfg/registry.py b/repoze/bfg/registry.py index 5dda3f7a6..cab95933b 100644 --- a/repoze/bfg/registry.py +++ b/repoze/bfg/registry.py @@ -92,6 +92,10 @@ def asbool(s): return s.lower() in ('t', 'true', 'y', 'yes', 'on', '1') def get_options(kw, environ=os.environ): + """ Update PasteDeploy application settings keywords with + framework-specific key/value pairs (e.g. find + 'BFG_DEBUG_AUTHORIZATION' in os.environ and jam into keyword + args).""" # environ is passed in for unit tests eget = environ.get config_debug_all = kw.get('debug_all', '') @@ -109,13 +113,16 @@ def get_options(kw, environ=os.environ): config_unicode_path_segments = kw.get('unicode_path_segments', '') effective_unicode_path_segments = asbool(eget('BFG_UNICODE_PATH_SEGMENTS', config_unicode_path_segments)) - return { + update = { 'debug_authorization': effective_debug_all or effective_debug_auth, 'debug_notfound': effective_debug_all or effective_debug_notfound, 'reload_templates': effective_reload_templates, 'unicode_path_segments': effective_unicode_path_segments, } + kw.update(update) + return kw + from zope.testing.cleanup import addCleanUp try: addCleanUp(original_getSiteManager.reset) diff --git a/repoze/bfg/tests/test_registry.py b/repoze/bfg/tests/test_registry.py index f10fe6a52..9bf09399f 100644 --- a/repoze/bfg/tests/test_registry.py +++ b/repoze/bfg/tests/test_registry.py @@ -133,6 +133,11 @@ class TestGetOptions(unittest.TestCase): {'BFG_UNICODE_PATH_SEGMENTS':'1'}) self.assertEqual(result['unicode_path_segments'], True) + def test_originals_kept(self): + get_options = self._getFUT() + result = get_options({'a':'i am so a'}) + self.assertEqual(result['a'], 'i am so a') + class TestSettings(unittest.TestCase): def _getTargetClass(self): from repoze.bfg.registry import Settings |
