diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2014-06-25 12:39:23 -0400 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2014-06-25 12:40:55 -0400 |
commit | 6276bb093b3cfa40d949e6a29081c68bd4422956 (patch) | |
tree | de93e3e85890a2028eb01a9c19634d6ba40c38b6 | |
parent | 6c7a8b3ee9658c4bb2a2d72f241720861d1da56f (diff) | |
download | pecan-6276bb093b3cfa40d949e6a29081c68bd4422956.tar.gz |
Fix a bug that broke `default_renderer = json`.
Change-Id: Ie57feadb6efe664c1bc3c39debcb21c3355f210c
Fixes bug 1332501
-rw-r--r-- | pecan/core.py | 4 | ||||
-rw-r--r-- | pecan/tests/test_base.py | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/pecan/core.py b/pecan/core.py index 44bad0e..eb3fe69 100644 --- a/pecan/core.py +++ b/pecan/core.py @@ -526,7 +526,9 @@ class PecanBase(object): template = content_types.get(pecan_state['content_type']) # check if for controller override of template - template = pecan_state.get('override_template', template) + template = pecan_state.get('override_template', template) or ( + 'json' if self.default_renderer == 'json' else None + ) pecan_state['content_type'] = pecan_state.get( 'override_content_type', pecan_state['content_type'] diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py index 81471ec..c076139 100644 --- a/pecan/tests/test_base.py +++ b/pecan/tests/test_base.py @@ -1520,6 +1520,19 @@ class TestEngines(PecanTestCase): assert r.status_int == 200 assert b_("<h1>Hello, Jonathan!</h1>") in r.body + def test_default_json_renderer(self): + + class RootController(object): + @expose() + def index(self, name='Bill'): + return dict(name=name) + + app = TestApp(Pecan(RootController(), default_renderer='json')) + r = app.get('/') + assert r.status_int == 200 + result = dict(json.loads(r.body.decode())) + assert result == {'name': 'Bill'} + class TestDeprecatedRouteMethod(PecanTestCase): |