From ce9b9baba16799041e6a4e819eef894ae9ff516d Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 28 May 2011 20:08:25 -0400 Subject: move is_response back to pyramid.view --- pyramid/exceptions.py | 17 +---------------- pyramid/view.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/pyramid/exceptions.py b/pyramid/exceptions.py index 354679a22..8705ed1fb 100644 --- a/pyramid/exceptions.py +++ b/pyramid/exceptions.py @@ -1078,21 +1078,6 @@ def redirect(url, code=302, **kw): exc = status_map[code] raise exc(location=url, **kw).exception -def is_response(ob): - """ Return ``True`` if ``ob`` implements the interface implied by - :ref:`the_response`. ``False`` if not. - - .. note:: This isn't a true interface or subclass check. Instead, it's a - duck-typing check, as response objects are not obligated to be of a - particular class or provide any particular Zope interface.""" - - # response objects aren't obligated to implement a Zope interface, - # so we do it the hard way - if ( hasattr(ob, 'app_iter') and hasattr(ob, 'headerlist') and - hasattr(ob, 'status') ): - return True - return False - def default_exceptionresponse_view(context, request): if not isinstance(context, Exception): # backwards compat for an exception response view registered via @@ -1103,5 +1088,5 @@ def default_exceptionresponse_view(context, request): return context __all__.extend(['NotFound', 'Forbidden', 'PredicateMismatch', 'URLDecodeError', - 'ConfigurationError', 'abort', 'redirect', 'is_response', + 'ConfigurationError', 'abort', 'redirect', 'default_exceptionresponse_view']) diff --git a/pyramid/view.py b/pyramid/view.py index d6b666cf2..975464124 100644 --- a/pyramid/view.py +++ b/pyramid/view.py @@ -10,7 +10,6 @@ from pyramid.interfaces import IViewClassifier from pyramid.exceptions import HTTPFound from pyramid.exceptions import default_exceptionresponse_view -from pyramid.exceptions import is_response # API from pyramid.renderers import RendererHelper from pyramid.static import static_view from pyramid.threadlocal import get_current_registry @@ -312,4 +311,18 @@ See also :ref:`changing_the_notfound_view`. """ +def is_response(ob): + """ Return ``True`` if ``ob`` implements the interface implied by + :ref:`the_response`. ``False`` if not. + + .. note:: This isn't a true interface or subclass check. Instead, it's a + duck-typing check, as response objects are not obligated to be of a + particular class or provide any particular Zope interface.""" + + # response objects aren't obligated to implement a Zope interface, + # so we do it the hard way + if ( hasattr(ob, 'app_iter') and hasattr(ob, 'headerlist') and + hasattr(ob, 'status') ): + return True + return False -- cgit v1.2.3