Re: [web2py] Re: Raising HTTP errors as JSON?

2013-03-06 Thread Alec Taylor
Not to worry, already upgraded all my servers On Wed, Mar 6, 2013 at 11:58 PM, Niphlod wrote: > If on old version, you can zero out the returning an iterator (or a > list) instead of the body, i.e > raise HTTP(401, [json.dumps(whatever)]) > vs > raise HTTP(401, json.dumps(whatever)) > > > On

Re: [web2py] Re: Raising HTTP errors as JSON?

2013-03-06 Thread Niphlod
If on old version, you can zero out the returning an iterator (or a list) instead of the body, i.e raise HTTP(401, [json.dumps(whatever)]) vs raise HTTP(401, json.dumps(whatever)) On Wednesday, March 6, 2013 12:15:07 PM UTC+1, Alec Taylor wrote: > > 401 was actually the error code that would

Re: [web2py] Re: Raising HTTP errors as JSON?

2013-03-06 Thread Alec Taylor
FYI: I get: Content-Type: application/json When I have: `response.view = 'generic.json'`, e.g.: on a `@request.restful()` On just a regular GET request on a `@service.json` endpoint I get: Content-Type: text/html; charset=UTF-8 And with a POST that has its args given with `-d` curl arg I get:

Re: [web2py] Re: Raising HTTP errors as JSON?

2013-03-06 Thread Alec Taylor
401 was actually the error code that would be relevant there. Surprised that the XML comments were removed in 2.4.2; had been tracing the commits. Just checked and noticed I am on 02.21.10.15.58 and it was fixed in 02.22.18.44.48 >.< Thanks for the other tips; should be helpful :D On Wed, Mar 6,

Re: [web2py] Re: Raising HTTP errors as JSON?

2013-03-06 Thread Ricardo Pedroso
On Wed, Mar 6, 2013 at 9:43 AM, Alec Taylor wrote: > Oh, looks like it works on an endpoint level; not sure how to get rid > of the XML style comment though > > Output from curl: > >> GET /arbg/error HTTP/1.1 >> Host: localhost >> Accept: */* >> > > < HTTP/1.1 404 NOT FOUND > < Set-Cookie: sessi

Re: [web2py] Re: Raising HTTP errors as JSON?

2013-03-06 Thread Alec Taylor
Oh, looks like it works on an endpoint level; not sure how to get rid of the XML style comment though Output from curl: > GET /arbg/error HTTP/1.1 > Host: localhost > Accept: */* > < HTTP/1.1 404 NOT FOUND < Set-Cookie: session_id_arbg=127.0.0.1-d5613ca1-ff65-4c0e-a5ce-737c6024655d; Path=/ < C

[web2py] Re: Raising HTTP errors as JSON?

2013-03-06 Thread Niphlod
what did you expect ? On Wednesday, March 6, 2013 9:37:26 AM UTC+1, Alec Taylor wrote: > > How do I raise HTTP errors as JSON? > > My attempt: > > In [1]: import json > > In [2]: from gluon.http import HTTP > > In [3]: raise HTTP(412, json.dumps({'error': 'must accept terms'})) > ---