summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2011-07-11 21:08:27 -0500
committerMichael Merickel <michael@merickel.org>2011-07-14 19:56:44 -0500
commit54376af6ae324606a96bbc92629cfb2b0b375e12 (patch)
treede851fdc670cb7a9fc16cf574fe5e4d4654b06ef
parenta02407ee018a17a0186b3e139b15e05f8ff1c795 (diff)
downloadpyramid-54376af6ae324606a96bbc92629cfb2b0b375e12.tar.gz
pyramid-54376af6ae324606a96bbc92629cfb2b0b375e12.tar.bz2
pyramid-54376af6ae324606a96bbc92629cfb2b0b375e12.zip
Reverted get_root back to its behavior of expecting a router instance.
-rw-r--r--pyramid/scripting.py5
-rw-r--r--pyramid/tests/test_scripting.py22
2 files changed, 4 insertions, 23 deletions
diff --git a/pyramid/scripting.py b/pyramid/scripting.py
index e04c52a08..79523dff1 100644
--- a/pyramid/scripting.py
+++ b/pyramid/scripting.py
@@ -13,10 +13,7 @@ def get_root(app, request=None):
:app:`Pyramid` application root factory. A request is constructed
using :meth:`pyramid.scripting.make_request` and passed to the root
factory if ``request`` is None."""
- if hasattr(app, 'registry'):
- registry = app.registry
- else:
- registry = global_registries.last
+ registry = app.registry
if request is None:
request = make_request('/', registry)
threadlocals = {'registry':registry, 'request':request}
diff --git a/pyramid/tests/test_scripting.py b/pyramid/tests/test_scripting.py
index 6ed1325ce..315ab222f 100644
--- a/pyramid/tests/test_scripting.py
+++ b/pyramid/tests/test_scripting.py
@@ -35,39 +35,23 @@ class TestGetRoot(unittest.TestCase):
pushed = app.threadlocal_manager.pushed[0]
self.assertEqual(pushed['request'].environ['path'], '/')
- def test_it_with_no_registry(self):
- from pyramid.config import global_registries
- app = DummyApp()
- # keep registry local so that global_registries is cleared after
- registry = DummyRegistry(DummyFactory)
- global_registries.add(registry)
- root, closer = self._callFUT(app)
- self.assertEqual(len(app.threadlocal_manager.pushed), 1)
- pushed = app.threadlocal_manager.pushed[0]
- self.assertEqual(pushed['request'].registry, registry)
-
class TestMakeRequest(unittest.TestCase):
def _callFUT(self, path='/', registry=None):
from pyramid.scripting import make_request
return make_request(path, registry)
- def test_it(self):
+ def test_it_with_registry(self):
request = self._callFUT('/', dummy_registry)
self.assertEqual(request.environ['path'], '/')
self.assertEqual(request.registry, dummy_registry)
- def test_it_with_nondefault_path(self):
- request = self._callFUT('/users/login', dummy_registry)
- self.assertEqual(request.environ['path'], '/users/login')
- self.assertEqual(request.registry, dummy_registry)
-
def test_it_with_no_registry(self):
from pyramid.config import global_registries
# keep registry local so that global_registries is cleared after
registry = DummyRegistry(DummyFactory)
global_registries.add(registry)
- request = self._callFUT()
- self.assertEqual(request.environ['path'], '/')
+ request = self._callFUT('/hello')
+ self.assertEqual(request.environ['path'], '/hello')
self.assertEqual(request.registry, registry)
class Dummy: