summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Abramowitz <marc@marc-abramowitz.com>2016-03-07 11:15:22 -0800
committerMarc Abramowitz <marc@marc-abramowitz.com>2016-03-07 11:15:22 -0800
commit5e90f570d3b182f8d2aeaa5b337bec426ddf94d3 (patch)
treee98676a15a5f0aae8860ecbee66a35b083387772
parent26408ad7397e205daabe4b07cc50c80fdfb830ea (diff)
parenteeeb0167accbb26e6205a74846f93e82561d1d1d (diff)
downloadpastedeploy-5e90f570d3b182f8d2aeaa5b337bec426ddf94d3.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.py9
-rw-r--r--tests/test_config.py7
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',