diff options
author | Marc Abramowitz <marc@marc-abramowitz.com> | 2016-03-07 11:15:22 -0800 |
---|---|---|
committer | Marc Abramowitz <marc@marc-abramowitz.com> | 2016-03-07 11:15:22 -0800 |
commit | 3d294d4c2146e5793d7c44b628387e4f53d798e2 (patch) | |
tree | e98676a15a5f0aae8860ecbee66a35b083387772 | |
parent | eeefeb7a6deeff9ed50f6ed6a62e4fb5972d315a (diff) | |
parent | 71e021d87200e1926f373c0536aa4888c6869f7a (diff) | |
download | pastedeploy-git-3d294d4c2146e5793d7c44b628387e4f53d798e2.tar.gz |
Merged in lrowe/pastedeploy/lrowe/allow-global_conf-to-override-defaults-s-1417659209217 (pull request #7)
Allow global_conf to override defaults, see: #7.
-rw-r--r-- | paste/deploy/loadwsgi.py | 9 | ||||
-rw-r--r-- | tests/test_config.py | 7 |
2 files changed, 8 insertions, 8 deletions
diff --git a/paste/deploy/loadwsgi.py b/paste/deploy/loadwsgi.py index 8b2849d..fc766b0 100644 --- a/paste/deploy/loadwsgi.py +++ b/paste/deploy/loadwsgi.py @@ -406,12 +406,11 @@ class ConfigLoader(_Loader): global_conf=global_conf) section = self.find_config_section( object_type, name=name) - if global_conf is None: - global_conf = {} - else: - global_conf = global_conf.copy() defaults = self.parser.defaults() - global_conf.update(defaults) + _global_conf = defaults.copy() + if global_conf is not None: + _global_conf.update(global_conf) + global_conf = _global_conf local_conf = {} global_additions = {} get_from_globals = {} diff --git a/tests/test_config.py b/tests/test_config.py index de40a2a..f64dd21 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -98,7 +98,8 @@ def test_foreign_config(): 'bob': 'your uncle'}) eq_(app.global_conf, { 'def1': 'a', - 'def2': 'from include', + # Note overwrite of DEFAULT value from foreign config + 'def2': 'b', 'def3': 'c', 'basepath': config_path, 'glob': 'override', @@ -150,8 +151,8 @@ def test_global_conf(): global_conf={'def2': 'TEST DEF 2', 'inherit': 'bazbar'}) eq_(conf, { 'def1': 'a', - # Note that this gets overwritten: - 'def2': 'b', + # Note overwrite of DEFAULT value + 'def2': 'TEST DEF 2', 'basepath': os.path.join(here, 'sample_configs'), 'here': config_path, 'inherit': 'bazbar', |