summaryrefslogtreecommitdiff
path: root/pecan
diff options
context:
space:
mode:
authorRyan Petrello <lists@ryanpetrello.com>2014-05-19 16:56:43 -0400
committerRyan Petrello <lists@ryanpetrello.com>2014-05-19 17:26:29 -0400
commit9cea1bb00943c89a6fc1e83434c39493a31ace9d (patch)
treef00000513f4c607e923ff81808cdb12fd0762ac6 /pecan
parentedeff73f438517d862a47b30a6a0f87e0cdd033e (diff)
downloadpecan-9cea1bb00943c89a6fc1e83434c39493a31ace9d.tar.gz
Allow controllers to return an explicit `webob.Response` object.
Change-Id: I5e827eed73962a0a6f5d879224759a4d13888751
Diffstat (limited to 'pecan')
-rw-r--r--pecan/core.py3
-rw-r--r--pecan/tests/test_base.py17
2 files changed, 20 insertions, 0 deletions
diff --git a/pecan/core.py b/pecan/core.py
index 76fc975..6a096b5 100644
--- a/pecan/core.py
+++ b/pecan/core.py
@@ -519,6 +519,9 @@ class Pecan(object):
# care of filling it out
if result is response:
return
+ elif isinstance(result, Response):
+ state.response = result
+ return
raw_namespace = result
diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py
index 050ac6d..f4bd64b 100644
--- a/pecan/tests/test_base.py
+++ b/pecan/tests/test_base.py
@@ -7,6 +7,7 @@ if sys.version_info < (2, 7):
else:
import unittest # pragma: nocover
+import webob
from webtest import TestApp
import six
from six import b as b_
@@ -937,6 +938,22 @@ class TestStreamedResponse(PecanTestCase):
assert r.body == b_('plain text')
+class TestManualResponse(PecanTestCase):
+
+ def test_manual_response(self):
+
+ class RootController(object):
+ @expose()
+ def index(self):
+ resp = webob.Response(response.environ)
+ resp.body = b_('Hello, World!')
+ return resp
+
+ app = TestApp(Pecan(RootController()))
+ r = app.get('/')
+ assert r.body == b_('Hello, World!')
+
+
class TestThreadLocalState(PecanTestCase):
def test_thread_local_dir(self):