Chris McDonough
2015-06-05 627ae840e550b05948b3c7e4388080bf957c6a74
merge from master
2 files modified
30 ■■■■■ changed files
pyramid/tests/test_view.py 14 ●●●●● patch | view | raw | blame | history
pyramid/view.py 16 ●●●●● patch | view | raw | blame | history
pyramid/tests/test_view.py
@@ -185,6 +185,20 @@
        self.assertEqual(response.status, '200 OK')
        self.assertEqual(response.app_iter, ['anotherview'])
    def test_call_view_with_request_iface_on_request(self):
        # See https://github.com/Pylons/pyramid/issues/1643
        from zope.interface import Interface
        class IWontBeFound(Interface): pass
        context = self._makeContext()
        request = self._makeRequest()
        request.request_iface = IWontBeFound
        response = DummyResponse('aview')
        view = make_view(response)
        self._registerView(request.registry, view, 'aview')
        response = self._callFUT(context, request, name='aview')
        self.assertEqual(response.status, '200 OK')
        self.assertEqual(response.app_iter, ['aview'])
class RenderViewToIterableTests(BaseTest, unittest.TestCase):
    def _callFUT(self, *arg, **kw):
        from pyramid.view import render_view_to_iterable
pyramid/view.py
@@ -49,6 +49,19 @@
        registry = get_current_registry()
    context_iface = providedBy(context)
    # We explicitly pass in the interfaces provided by the request as
    # request_iface to _call_view; we don't want _call_view to use
    # request.request_iface, because render_view_to_response and friends are
    # pretty much limited to finding views that are not views associated with
    # routes, and the only thing request.request_iface is used for is to find
    # route-based views.  The render_view_to_response API is (and always has
    # been) a stepchild API reserved for use of those who actually use
    # traversal.  Doing this fixes an infinite recursion bug introduced in
    # Pyramid 1.6a1, and causes the render_view* APIs to behave as they did in
    # 1.5 and previous. We should probably provide some sort of different API
    # that would allow people to find views for routes.  See
    # https://github.com/Pylons/pyramid/issues/1643 for more info.
    request_iface = providedBy(request)
    response = _call_view(
        registry,
@@ -56,7 +69,8 @@
        context,
        context_iface,
        name,
        secure = secure,
        secure=secure,
        request_iface=request_iface,
        )
    return response # NB: might be None