[web2py] Re: IOS, Json, Web2py.

2013-07-25 Thread Ray (a.k.a. Iceberg)
On Friday, July 26, 2013 12:45:58 AM UTC+8, Ray (a.k.a. Iceberg) wrote: > > > > On Tuesday, June 11, 2013 5:14:42 AM UTC+8, Niphlod wrote: >> >> ps: recent web2py releases should parse application/json POSTs >> transparently, no need to request.body.read() anymore it goes all in >> request.

[web2py] Re: IOS, Json, Web2py.

2013-07-25 Thread Ray (a.k.a. Iceberg)
On Tuesday, June 11, 2013 5:14:42 AM UTC+8, Niphlod wrote: > > ps: recent web2py releases should parse application/json POSTs > transparently, no need to request.body.read() anymore it goes all in > request.vars and request.post_vars as usual. > > Sorry to chime in an old thread, but which

[web2py] Re: IOS, Json, Web2py.

2013-06-10 Thread Massimo Di Pierro
welll... this should work: db.someTable.insert(**data) but insert returns a number (actually a Reference object) and therefore you cannot pass it to a dict as in: dict(db.someTable.insert(**data)) Insert and validate returns a dict instead (containing the id and errors) On Monday, 10 Ju

[web2py] Re: IOS, Json, Web2py.

2013-06-10 Thread Philipp Müller
Thanks so much. This works for dict(db.someTable.validate_and_insert(**data)) but for some reason not for dict(db.someTable.insert(**data)) That's fine for me, I'm just wondering though. Btw: What exactly does ** do in this case? Thanks again and regards, Philipp Am Montag, 10. Juni 2013 23:

[web2py] Re: IOS, Json, Web2py.

2013-06-10 Thread Niphlod
ps: recent web2py releases should parse application/json POSTs transparently, no need to request.body.read() anymore it goes all in request.vars and request.post_vars as usual. On Monday, June 10, 2013 11:02:36 PM UTC+2, Massimo Di Pierro wrote: > > return dict(db.someDatabase.insert(**data)

[web2py] Re: IOS, Json, Web2py.

2013-06-10 Thread Massimo Di Pierro
return dict(db.someDatabase.insert(**data)) #or return dict(db.someDatabase.validate_and_insert(**data)) On Monday, 10 June 2013 15:58:16 UTC-5, Philipp Müller wrote: > > So far, this seems to work fine. I struggle though when trying to write > this data in my database. > > I tried doing: > data

[web2py] Re: IOS, Json, Web2py.

2013-06-10 Thread Philipp Müller
So far, this seems to work fine. I struggle though when trying to write this data in my database. I tried doing: data = sj.loads(request.body.read()) #and later return dict(db.someDatabase.insert(data)) #or return dict(db.someDatabase.validate_and_insert(data)) for all of which I got the error m

[web2py] Re: IOS, Json, Web2py.

2012-10-24 Thread Niphlod
For future users reading this thread... this means that the Iphone sent the JSON object POSTing to the page directly in the data stream, without "the usual" form encoding. For that, you can access what has been posted "in raw format" with request.body.read(). PS: Keep the code small import glu

[web2py] Re: IOS, Json, Web2py.

2012-10-24 Thread Mchurch
import gluon.contrib.simplejson data = gluon.contrib.simplejson.loads(request.body.read()) That was the trick Thank You Niphlod, You put me in the right direction. IOS + WEB2PY = beautiful combination!! Mchurch Il giorno mercoledì 24 ottobre 2012 09:01:40 UTC+2, Mchurch ha scritto: > > Hi

[web2py] Re: IOS, Json, Web2py.

2012-10-24 Thread Mchurch
Hi Niphlod, did You hope to be free of me so soon? :) Looking at web2py errors, if i make a post request values are empty (not if i make a GET, but the final result is the same). Using "CHARLES, web debugging proxy" i can see that data are dispatched with correct values and correct Content-Type (

[web2py] Re: IOS, Json, Web2py.

2012-10-23 Thread Niphlod
almost dinner time here :P On Tuesday, October 23, 2012 5:44:45 PM UTC+2, Mchurch wrote: > > I'll try, thanks. > Ps. Did You eat some snakes for breakfast? > :) --

[web2py] Re: IOS, Json, Web2py.

2012-10-23 Thread Mchurch
I'll try, thanks. Ps. Did You eat some snakes for breakfast? :) --

[web2py] Re: IOS, Json, Web2py.

2012-10-23 Thread Niphlod
if you PRINT *something*, you don't return *something* to the device, but you can see the *something* on the console, .i.e. the shell where you started web2py.py . I'm guessing that at least you have access to your developing environment :P ! On Tuesday, October 23, 2012 3:38:26 PM UTC+2, Mchur

[web2py] Re: IOS, Json, Web2py.

2012-10-23 Thread Mchurch
but i don't open that page in a browser, i'm just sending data. Should I use a console error like firebug may be? Sorry for the stupid question, but if i open the page in a browser without the data from ios i get from web2py "Expected string o JSON...". I'm lost somewhere between IOs and web2py!

[web2py] Re: IOS, Json, Web2py.

2012-10-23 Thread Niphlod
What I said was that if you print on the server-side you can see what happens on the "endpoint" you have control of: not IOS, the webserver! On Tuesday, October 23, 2012 3:27:46 PM UTC+2, Mchurch wrote: > > from the app, no more errors, always that "500". > >> try to print out request.vars and re

[web2py] Re: IOS, Json, Web2py.

2012-10-23 Thread Mchurch
from the app, no more errors, always that "500". > try to print out request.vars and request.vars.body.read() and see their > contents. > I have to think and study more about that; it's a json call, i can't reach directly that page, i should give the server response back to the app to check w

[web2py] Re: IOS, Json, Web2py.

2012-10-23 Thread Niphlod
that's the problem when you don't know what something does. try to print out request.vars and request.vars.body() and see their contents. PS: you can also watch the errors for the app to investigate the issue (if your phone is getting a 500, it's probable that the error is logged in web2p

[web2py] Re: IOS, Json, Web2py.

2012-10-23 Thread Mchurch
I followed instructons, > If you're using AFHTTPClient, set the parameterEncoding property to > AFJSONParameterEncoding. Any method on that HTTP client with aparameters > argument > will now encode the passed object into a JSON string and set the HTTP body > and Content-Type header appropriate

[web2py] Re: IOS, Json, Web2py.

2012-10-23 Thread Niphlod
in what format are you posting json back to the server (not the format of the json, that is of course json ... just the way you use to transmit data) ? are you using application/x-www-form-urlencoded ? multipart/form-data ? binary post ? On Tuesday, October 23, 2012 10:23:16 AM UTC+2, Mchurch w