| | |
| | | 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 |
| | |
| | | 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, |
| | |
| | | context, |
| | | context_iface, |
| | | name, |
| | | secure = secure, |
| | | secure=secure, |
| | | request_iface=request_iface, |
| | | ) |
| | | |
| | | return response # NB: might be None |