summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt8
-rw-r--r--pyramid/paster.py19
-rw-r--r--pyramid/tests/test_paster.py35
3 files changed, 40 insertions, 22 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index af78b714d..643e0ed7b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,7 +1,13 @@
Next release
============
-- ...
+Bug Fixes
+---------
+
+- The ``proutes`` command tried too hard to resolve the view for printing,
+ resulting in exceptions when an exceptional root factory was encountered.
+ Instead of trying to resolve the view, if it cannot, it will now just print
+ ``<unknown>``.
1.0a8 (2010-12-27)
==================
diff --git a/pyramid/paster.py b/pyramid/paster.py
index 57dac6b32..5efbae51c 100644
--- a/pyramid/paster.py
+++ b/pyramid/paster.py
@@ -201,19 +201,10 @@ class PRoutesCommand(PCommand):
request_iface = registry.queryUtility(IRouteRequest,
name=route.name)
view_callable = None
- if request_iface is not None:
- if route.factory is None:
- context_iface = Interface
- else:
- request = Request.blank('/')
- inst = route.factory(request)
- context_iface = providedBy(inst)
- # try with factory instance as context; views registered for
- # a more general interface will be found if the context
- # iface is very specific
+ if (request_iface is None) or (route.factory is not None):
+ self.out(fmt % (route.name, route.pattern, '<unknown>'))
+ else:
view_callable = registry.adapters.lookup(
- (IViewClassifier, request_iface, context_iface),
+ (IViewClassifier, request_iface, Interface),
IView, name='', default=None)
- self.out(fmt % (route.name, route.pattern, view_callable))
-
-
+ self.out(fmt % (route.name, route.pattern, view_callable))
diff --git a/pyramid/tests/test_paster.py b/pyramid/tests/test_paster.py
index a5f613f8e..35349b7c7 100644
--- a/pyramid/tests/test_paster.py
+++ b/pyramid/tests/test_paster.py
@@ -133,7 +133,31 @@ class TestPRoutesCommand(unittest.TestCase):
self.assertEqual(result, None)
self.assertEqual(L, [])
+ def test_single_route_no_route_registered(self):
+ command = self._makeOne()
+ route = DummyRoute('a', '/a')
+ mapper = DummyMapper(route)
+ command._get_mapper = lambda *arg: mapper
+ L = []
+ command.out = L.append
+ app = DummyApp()
+ loadapp = DummyLoadApp(app)
+ command.loadapp = (loadapp,)
+ command.args = ('/foo/bar/myapp.ini', 'myapp')
+ result = command.command()
+ self.assertEqual(result, None)
+ self.assertEqual(len(L), 3)
+ self.assertEqual(L[-1].split(), ['a', '/a', '<unknown>'])
+
def test_single_route_no_views_registered(self):
+ from zope.interface import Interface
+ from pyramid.registry import Registry
+ from pyramid.interfaces import IRouteRequest
+ registry = Registry()
+ def view():pass
+ class IMyRoute(Interface):
+ pass
+ registry.registerUtility(IMyRoute, IRouteRequest, name='a')
command = self._makeOne()
route = DummyRoute('a', '/a')
mapper = DummyMapper(route)
@@ -141,13 +165,14 @@ class TestPRoutesCommand(unittest.TestCase):
L = []
command.out = L.append
app = DummyApp()
+ app.registry = registry
loadapp = DummyLoadApp(app)
command.loadapp = (loadapp,)
command.args = ('/foo/bar/myapp.ini', 'myapp')
result = command.command()
self.assertEqual(result, None)
self.assertEqual(len(L), 3)
- self.assertEqual(L[-1].split(), ['a', '/a', 'None'])
+ self.assertEqual(L[-1].split()[:3], ['a', '/a', 'None'])
def test_single_route_one_view_registered(self):
from zope.interface import Interface
@@ -181,7 +206,6 @@ class TestPRoutesCommand(unittest.TestCase):
def test_single_route_one_view_registered_with_factory(self):
from zope.interface import Interface
- from zope.interface import implements
from pyramid.registry import Registry
from pyramid.interfaces import IRouteRequest
from pyramid.interfaces import IViewClassifier
@@ -190,8 +214,6 @@ class TestPRoutesCommand(unittest.TestCase):
def view():pass
class IMyRoot(Interface):
pass
- class Root(object):
- implements(IMyRoot)
class IMyRoute(Interface):
pass
registry.registerAdapter(view,
@@ -199,8 +221,7 @@ class TestPRoutesCommand(unittest.TestCase):
IView, '')
registry.registerUtility(IMyRoute, IRouteRequest, name='a')
command = self._makeOne()
- def factory(request):
- return Root()
+ def factory(request): pass
route = DummyRoute('a', '/a', factory=factory)
mapper = DummyMapper(route)
command._get_mapper = lambda *arg: mapper
@@ -214,7 +235,7 @@ class TestPRoutesCommand(unittest.TestCase):
result = command.command()
self.assertEqual(result, None)
self.assertEqual(len(L), 3)
- self.assertEqual(L[-1].split()[:4], ['a', '/a', '<function', 'view'])
+ self.assertEqual(L[-1].split()[:3], ['a', '/a', '<unknown>'])
def test__get_mapper(self):
from pyramid.registry import Registry