summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt5
-rw-r--r--pyramid/config.py7
-rw-r--r--pyramid/tests/test_view.py32
-rw-r--r--pyramid/view.py5
4 files changed, 30 insertions, 19 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 0f71105fe..3dd4f6cfe 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -31,6 +31,11 @@ Bug Fixes
- Added ``egg:repoze.retry#retry`` middleware to the WSGI pipeline in ZODB
templates (retry ZODB conflict errors which occur in normal operations).
+- Removed duplicate implementations of ``is_response``. Two competing
+ implementations existed: one in ``pyramid.config`` and one in
+ ``pyramid.view``. Now the one defined in ``pyramid.view`` is used
+ internally by ``pyramid.config`` and continues to be advertised as an API.
+
1.0b3 (2011-01-28)
==================
diff --git a/pyramid/config.py b/pyramid/config.py
index 68b9ca449..390df8b34 100644
--- a/pyramid/config.py
+++ b/pyramid/config.py
@@ -87,6 +87,7 @@ from pyramid.urldispatch import RoutesMapper
from pyramid.util import DottedNameResolver
from pyramid.view import default_exceptionresponse_view
from pyramid.view import render_view_to_response
+from pyramid.view import is_response
MAX_ORDER = 1 << 30
DEFAULT_PHASH = md5().hexdigest()
@@ -2989,12 +2990,6 @@ def translator(msg):
localizer = get_localizer(request)
return localizer.translate(msg)
-def is_response(ob):
- if ( hasattr(ob, 'app_iter') and hasattr(ob, 'headerlist') and
- hasattr(ob, 'status') ):
- return True
- return False
-
def isexception(o):
if IInterface.providedBy(o):
if IException.isEqualOrExtendedBy(o):
diff --git a/pyramid/tests/test_view.py b/pyramid/tests/test_view.py
index 61bf85192..43b9e2766 100644
--- a/pyramid/tests/test_view.py
+++ b/pyramid/tests/test_view.py
@@ -196,15 +196,29 @@ class TestIsResponse(unittest.TestCase):
response = None
self.assertEqual(self._callFUT(response), False)
- def test_partial_inst(self):
- response = DummyResponse()
- response.app_iter = None
- self.assertEqual(self._callFUT(response), False)
-
- def test_status_not_string(self):
- response = DummyResponse()
- response.status = None
- self.assertEqual(self._callFUT(response), False)
+ def test_isnt_no_headerlist(self):
+ class Response(object):
+ pass
+ resp = Response
+ resp.status = '200 OK'
+ resp.app_iter = []
+ self.assertEqual(self._callFUT(resp), False)
+
+ def test_isnt_no_status(self):
+ class Response(object):
+ pass
+ resp = Response
+ resp.app_iter = []
+ resp.headerlist = ()
+ self.assertEqual(self._callFUT(resp), False)
+
+ def test_isnt_no_app_iter(self):
+ class Response(object):
+ pass
+ resp = Response
+ resp.status = '200 OK'
+ resp.headerlist = ()
+ self.assertEqual(self._callFUT(resp), False)
class TestViewConfigDecorator(unittest.TestCase):
def setUp(self):
diff --git a/pyramid/view.py b/pyramid/view.py
index 935104035..f16d2c38f 100644
--- a/pyramid/view.py
+++ b/pyramid/view.py
@@ -138,10 +138,7 @@ def is_response(ob):
# so we do it the hard way
if ( hasattr(ob, 'app_iter') and hasattr(ob, 'headerlist') and
hasattr(ob, 'status') ):
- if ( hasattr(ob.app_iter, '__iter__') and
- hasattr(ob.headerlist, '__iter__') and
- isinstance(ob.status, basestring) ) :
- return True
+ return True
return False
class view_config(object):