summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-08-26 01:45:12 -0400
committerChris McDonough <chrism@plope.com>2011-08-26 01:45:12 -0400
commit2a818aa445a5ed844c30d9a5df1f89adfab728d4 (patch)
treeed7118cb68838e585298e9737ebe9c08bf626d5d
parent8b62d750e1fb808ae2a22afa681972cda1d19c6d (diff)
downloadpyramid-2a818aa445a5ed844c30d9a5df1f89adfab728d4.tar.gz
pyramid-2a818aa445a5ed844c30d9a5df1f89adfab728d4.tar.bz2
pyramid-2a818aa445a5ed844c30d9a5df1f89adfab728d4.zip
- An include could not set a root factory successfully because the
Configurator constructor unconditionally registered one that would be treated as if it were "the word of the user".
-rw-r--r--CHANGES.txt4
-rw-r--r--pyramid/config/__init__.py3
-rw-r--r--pyramid/tests/test_config/test_init.py15
3 files changed, 17 insertions, 5 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 71b4fbecc..b1aa43539 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,6 +8,10 @@ Next release
- Mako rendering exceptions had the wrong value for an error message.
+- An include could not set a root factory successfully because the
+ Configurator constructor unconditionally registered one that would be
+ treated as if it were "the word of the user".
+
1.2a1 (2011-08-24)
==================
diff --git a/pyramid/config/__init__.py b/pyramid/config/__init__.py
index dc592977b..7575f4b2b 100644
--- a/pyramid/config/__init__.py
+++ b/pyramid/config/__init__.py
@@ -334,7 +334,8 @@ class Configurator(
for name, renderer in renderers:
self.add_renderer(name, renderer)
- self.set_root_factory(root_factory)
+ if root_factory is not None:
+ self.set_root_factory(root_factory)
if locale_negotiator:
self.set_locale_negotiator(locale_negotiator)
diff --git a/pyramid/tests/test_config/test_init.py b/pyramid/tests/test_config/test_init.py
index 0a787275d..da4e9522e 100644
--- a/pyramid/tests/test_config/test_init.py
+++ b/pyramid/tests/test_config/test_init.py
@@ -201,7 +201,15 @@ class ConfiguratorTests(unittest.TestCase):
config = self._makeOne()
self.assertEqual(config.registry.queryUtility(IRootFactory), None)
config.commit()
- self.assertTrue(config.registry.getUtility(IRootFactory))
+ self.assertEqual(config.registry.queryUtility(IRootFactory), None)
+
+ def test_ctor_with_root_factory(self):
+ from pyramid.interfaces import IRootFactory
+ factory = object()
+ config = self._makeOne(root_factory=factory)
+ self.assertEqual(config.registry.queryUtility(IRootFactory), None)
+ config.commit()
+ self.assertEqual(config.registry.queryUtility(IRootFactory), factory)
def test_ctor_alternate_renderers(self):
from pyramid.interfaces import IRendererFactory
@@ -512,15 +520,14 @@ class ConfiguratorTests(unittest.TestCase):
config.setup_registry(authorization_policy=policy)
config = self.assertRaises(ConfigurationExecutionError, config.commit)
- def test_setup_registry_default_root_factory(self):
+ def test_setup_registry_no_default_root_factory(self):
from pyramid.registry import Registry
from pyramid.interfaces import IRootFactory
reg = Registry()
config = self._makeOne(reg)
config.setup_registry()
- self.assertEqual(reg.queryUtility(IRootFactory), None)
config.commit()
- self.assertTrue(reg.getUtility(IRootFactory))
+ self.assertEqual(reg.queryUtility(IRootFactory), None)
def test_setup_registry_dottedname_root_factory(self):
from pyramid.registry import Registry