Vlad K.
unread,Nov 10, 2012, 10:09:08 AM11/10/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-...@googlegroups.com
Hello list,
I'm trying to use the built-in json renderer to produce a json formatted
response, but if I set the response content type to anything else,
despite of explicitly naming the renderer via view_config, the response
body is empty:
@view_config(route_name="test", request_method="POST", renderer="json")
def test_view(request)
request.response.content_type = "application/vnd.myformat+json"
return {"test" : "testing"}
The content type (and any other response header) is set properly, but
the body is empty. I suppose I can "manually" produce the json output
with a string renderer and some json.dumps() magic.
But is this expected? I haven't checked the internals, but I'd expect
the renderer to set default content type before the view callable is
executed and expect it to return a value which is JSON-serializeable,
regardless of what response headers does the callable set.
Thanks.