Question: How can I response a JSON with render='json',and set the header

2012-02-20 Thread Zane
Sample: @view_config(permission = 'view',route_name='addUser', renderer='json', custom_predicates=(allowed_methods('POST'),)) def add(request): post_data = request.json_body email = post_data['email'] headers = remember(request, email, max_age='86400') /* How to response this

Re: Question: How can I response a JSON with render='json',and set the header

2012-02-20 Thread Chris McDonough
On Mon, 2012-02-20 at 06:55 -0800, Zane wrote: Sample: @view_config(permission = 'view',route_name='addUser', renderer='json', custom_predicates=(allowed_methods('POST'),)) def add(request): post_data = request.json_body email = post_data['email'] headers = remember(request,

Re: Question: How can I response a JSON with render='json',and set the header

2012-02-20 Thread Zane
Thanks @Chris Yes.This is what I want, but now I receive a string {'succeed':True}, and before I add header in response is a object {'succeed':True} ( I using Ajax) I guess this cause the view_config(renderer='json') But How can I add header and return a Obj not a string. Sorry~ I'm a

Re: Question: How can I response a JSON with render='json',and set the header

2012-02-20 Thread Chris McDonough
On Mon, 2012-02-20 at 07:34 -0800, Zane wrote: Thanks @Chris Yes.This is what I want, but now I receive a string {'succeed':True}, and before I add header in response is a object {'succeed':True} ( I using Ajax) I guess this cause the view_config(renderer='json') But How can I add header

Re: Question: How can I response a JSON with render='json',and set the header

2012-02-20 Thread Zane
Oh~ Excuse my English~ May be I know the reason of my fault, I am using pyramid.security from pyramid.security import authenticated_userid, remember, forget @view_config(route_name='user', renderer='json') .. headers = remember(request, email, max_age='86400')

Re: Question: How can I response a JSON with render='json',and set the header

2012-02-20 Thread Zane
It's work *:*) Thank you @ yasaikun and Chris McDonough -- You received this message because you are subscribed to the Google Groups pylons-devel group. To view this discussion on the web visit https://groups.google.com/d/msg/pylons-devel/-/_x-s9OJqdhYJ. To post to this group, send email

Re: Question: How can I response a JSON with render='json',and set the header

2012-02-20 Thread cheeleong
No problem :) Regards, CL Chow Using Gmail? Please read this important notice: http://www.fsf.org/campaigns/jstrap/gmail?8483 On Tue, Feb 21, 2012 at 12:16 AM, Zane yaoaz...@gmail.com wrote: It's work *:*) Thank you @ yasaikun and Chris McDonough -- You received this message