Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Custom content type for json renderer
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vlad K.  
View profile  
 More options Nov 10 2012, 10:09 am
From: "Vlad K." <v...@haronmedia.com>
Date: Sat, 10 Nov 2012 16:09:08 +0100
Local: Sat, Nov 10 2012 10:09 am
Subject: Custom content type for json renderer

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vlad K.  
View profile  
 More options Nov 10 2012, 10:15 am
From: "Vlad K." <v...@haronmedia.com>
Date: Sat, 10 Nov 2012 16:14:37 +0100
Local: Sat, Nov 10 2012 10:14 am
Subject: Re: Custom content type for json renderer

My bad for failing to mention that this is Pyramid 1.4a3.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »