summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-05-28 20:08:25 -0400
committerChris McDonough <chrism@plope.com>2011-05-28 20:08:25 -0400
commitce9b9baba16799041e6a4e819eef894ae9ff516d (patch)
tree29749f511bed9002e34aa931294a57752c1e449c
parenta90d3231d0820dec17c26f31e0045b6edd6ebbc3 (diff)
downloadpyramid-ce9b9baba16799041e6a4e819eef894ae9ff516d.tar.gz
pyramid-ce9b9baba16799041e6a4e819eef894ae9ff516d.tar.bz2
pyramid-ce9b9baba16799041e6a4e819eef894ae9ff516d.zip
move is_response back to pyramid.view
-rw-r--r--pyramid/exceptions.py17
-rw-r--r--pyramid/view.py15
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