Marlysson Silva:
Yes, it would. However, when raising an exception as in the example code 
above, it doesn't.

Niphiod:
Thanks, it was really simple. I've tried other ways of setting the response 
code but it would either overwrite the body with "409 CONFLICT" or just 
return 200 OK.

Den tisdag 28 juni 2016 kl. 17:07:34 UTC+2 skrev Niphlod:
>
> or...given that the "big strange thing" is the status .... using the usual 
> syntax with 
>
> response.status = 409
>
> just before before returning  ?
>
> On Tuesday, June 28, 2016 at 4:44:44 PM UTC+2, Marlysson Silva wrote:
>>
>> The web2py would use generic views depending of extension of url.
>> Is it?
>>
>> Em terça-feira, 28 de junho de 2016 11:31:48 UTC-3, Joel Samuelsson 
>> escreveu:
>>>
>>> Hi,
>>>
>>> I'd like to respond with a complex data structure when raising a HTTP 
>>> 409 Conflict as response to a restful request but I can't seem to figure 
>>> out how. If possible, I'd like to reuse as much as possible from built-in 
>>> functions in web2py. The best idea I've gotten so far is something like 
>>> this:
>>>
>>> @auth.requires_login()
>>> @request.restful()
>>> def test():
>>> response.view = 'generic.'+request.extension
>>>
>>> def GET(*args,**vars):
>>> page = response.render('generic.'+request.extension, 
>>> dict(errors=["error1", "error2"]))
>>> raise HTTP(409, page)
>>>
>>> return locals()
>>>
>>>
>>> However, this does not set the appropiate Content-Type. Are there 
>>> easier/better ways to do what I want?
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to