[TurboGears] Re: simple_json now in use
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: Please consider at least keep json-py for this purpose. Well, it is not a big deal as adding it on top of TurboGears is not difficult anyway. Should json-py become a dependency for installing TG even if nothing on it requires incoming JSON? I believe it would be best to _add_ json-py later if your application needs it, keeping the requirements real for what the framework needs... (I also use something like you do...) -- Jorge Godoy [EMAIL PROTECTED]
[TurboGears] Re: simple_json now in use
On 12/25/05, Bob Ippolito [EMAIL PROTECTED] wrote: Ok, it's done in svn with the obvious API (simple_json.loads/load), which takes an optional encoding kwarg to specify what encoding to expect input to be in. It must be an ASCII based encoding though, something like UCS-2 needs to come in as unicode because that affects more than strings. The encoder in 1.0 encodes as ASCII represented as str instances by default (using \u escapes), you can turn that off and get 0.1 behavior by passing ensure_ascii=False, which will give you either a str or unicode string as output based on the normal Python str-unicode coercion rules. Nice! Thanks, Bob! Kevin
[TurboGears] Re: simple_json now in use
On 25 Dec 2005 07:44:48 -0200, Jorge Godoy [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: Please consider at least keep json-py for this purpose. Well, it is not a big deal as adding it on top of TurboGears is not difficult anyway. Should json-py become a dependency for installing TG even if nothing on it requires incoming JSON? I believe it would be best to _add_ json-py later if your application needs it, keeping the requirements real for what the framework needs... (I also use something like you do...) Yeah, it doesn't really make sense to include a dependency that doesn't get used. If there's no code in TurboGears to support doing something, there would still need to be documentation to tell users how to do that thing. And, if you're writing docs for it, you might as well add a line at the beginning that says easy_install json-py :) (But, in this case, Jeff was using json-py in core code and Bob has completely shortcircuited the need for json-py as is). Kevin
[TurboGears] Re: simple_json now in use
The new AjaxDataController expects all object data to arrive in JSON format. I was using json-py to parse the incoming JSON data. In keeping with the One Way To Do It, I think whatever JSON package TurboGears supports, MUST encode and decode JSON formatted data. Otherwise, developers will be forced to find an alternative solution for JSON. On 24 Dec, 2005, at 9:12 pm, Kevin Dangoor wrote: At the moment, TurboGears doesn't actually have anything that depends on incoming JSON (that I'm aware of... CatWalk, perhaps?) You can make REST-style requests just fine without being able to decode JSON. -- Jeff Watkins http://newburyportion.com/ Computers are like Old Testament gods; lots of rules and no mercy. -- Joseph Campbell
[TurboGears] Re: simple_json now in use
OK. I wasn't aware of that. Feel free to add the json-py requirement back in (or I'll do it when I get a chance). Kevin On 12/25/05, Jeff Watkins [EMAIL PROTECTED] wrote: The new AjaxDataController expects all object data to arrive in JSON format. I was using json-py to parse the incoming JSON data. In keeping with the One Way To Do It, I think whatever JSON package TurboGears supports, MUST encode and decode JSON formatted data. Otherwise, developers will be forced to find an alternative solution for JSON. On 24 Dec, 2005, at 9:12 pm, Kevin Dangoor wrote: At the moment, TurboGears doesn't actually have anything that depends on incoming JSON (that I'm aware of... CatWalk, perhaps?) You can make REST-style requests just fine without being able to decode JSON. -- Jeff Watkins http://newburyportion.com/ Computers are like Old Testament gods; lots of rules and no mercy. -- Joseph Campbell -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: simple_json now in use
I'll have decoding in simple_json for 0.2. It's almost done... need to hammer out a bug or three and write real tests. -bob On Dec 25, 2005, at 8:24 AM, Kevin Dangoor wrote: OK. I wasn't aware of that. Feel free to add the json-py requirement back in (or I'll do it when I get a chance). Kevin On 12/25/05, Jeff Watkins [EMAIL PROTECTED] wrote: The new AjaxDataController expects all object data to arrive in JSON format. I was using json-py to parse the incoming JSON data. In keeping with the One Way To Do It, I think whatever JSON package TurboGears supports, MUST encode and decode JSON formatted data. Otherwise, developers will be forced to find an alternative solution for JSON. On 24 Dec, 2005, at 9:12 pm, Kevin Dangoor wrote: At the moment, TurboGears doesn't actually have anything that depends on incoming JSON (that I'm aware of... CatWalk, perhaps?) You can make REST-style requests just fine without being able to decode JSON. -- Jeff Watkins http://newburyportion.com/ Computers are like Old Testament gods; lots of rules and no mercy. -- Joseph Campbell -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: simple_json now in use
Ok, it's done in svn with the obvious API (simple_json.loads/load), which takes an optional encoding kwarg to specify what encoding to expect input to be in. It must be an ASCII based encoding though, something like UCS-2 needs to come in as unicode because that affects more than strings. The encoder in 1.0 encodes as ASCII represented as str instances by default (using \u escapes), you can turn that off and get 0.1 behavior by passing ensure_ascii=False, which will give you either a str or unicode string as output based on the normal Python str-unicode coercion rules. I've version bumped to 1.0 because it's basically done other than future performance tweaks and maybe a bugfix or two. It's already on svn and in CheeseShop. The advantages-by-design over json-py are: 1. MIT licensed 2. Correct and fully extensible encoder 3. Correct decoder with encoding options 4. Python 2.3 support 5. Probably faster (have not benchmarked at all) The decoder does take advantage of some undocumented sre API, which binds it to sre and CPython, but that's basically an academic restriction in this context. The tests are kinda lazy and require nose. It's just a big doctest in simple_json/__init__.py. -bob On Dec 25, 2005, at 5:40 PM, Bob Ippolito wrote: I'll have decoding in simple_json for 0.2. It's almost done... need to hammer out a bug or three and write real tests. -bob On Dec 25, 2005, at 8:24 AM, Kevin Dangoor wrote: OK. I wasn't aware of that. Feel free to add the json-py requirement back in (or I'll do it when I get a chance). Kevin On 12/25/05, Jeff Watkins [EMAIL PROTECTED] wrote: The new AjaxDataController expects all object data to arrive in JSON format. I was using json-py to parse the incoming JSON data. In keeping with the One Way To Do It, I think whatever JSON package TurboGears supports, MUST encode and decode JSON formatted data. Otherwise, developers will be forced to find an alternative solution for JSON. On 24 Dec, 2005, at 9:12 pm, Kevin Dangoor wrote: At the moment, TurboGears doesn't actually have anything that depends on incoming JSON (that I'm aware of... CatWalk, perhaps?) You can make REST-style requests just fine without being able to decode JSON. -- Jeff Watkins http://newburyportion.com/ Computers are like Old Testament gods; lots of rules and no mercy. -- Joseph Campbell -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: simple_json now in use
Thanks very much, Bob. I'll convert the AjaxDataController to use the new API.On 25 Dec, 2005, at 7:21 pm, Bob Ippolito wrote:Ok, it's done in svn with the obvious API --Jeff Watkinshttp://newburyportion.com/Democracy n: A country where the newspapers are pro-American.
[TurboGears] Re: simple_json now in use
It's also API compatible with json-py, all you have to do is change the import.. e.g.:-import json+import simple_json as jsonHowever, json-py's API is horribly named and I would recommend a refactor towards the marshal/pickle-inspired API. This is trivial: change read(s) to loads(s) and write(obj) to dumps(obj).There are, of course, load and dump for file-like objects. Technically load is currently worthless because it just does loads(f.read()), but dump actually will write in chunks which may be useful in some conditions.-bobOn Dec 25, 2005, at 9:36 PM, Jeff Watkins wrote:Thanks very much, Bob. I'll convert the AjaxDataController to use the new API.On 25 Dec, 2005, at 7:21 pm, Bob Ippolito wrote:Ok, it's done in svn with the obvious API --Jeff Watkinshttp://newburyportion.com/Democracy n: A country where the newspapers are pro-American.
[TurboGears] Re: simple_json now in use
Bob Ippolito, el s�bado 24 de diciembre a las 11:13 me escribiste: That's orthogonal. Presumably, json-py is still used for decoding JSON. It does a fine job at that. According to the chanset [370], json-py was removed as a dependency. http://trac.turbogears.org/turbogears/changeset/370 -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ., \ GPG: 5F5A8D05 // F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05 / '' Hace diez años tenía una visión Pero nadie más la vió y hoy sigo pidiendo perdón
[TurboGears] Re: simple_json now in use
On 12/24/05, Leandro Lucarella [EMAIL PROTECTED] wrote: Bob Ippolito, el s�bado 24 de diciembre a las 11:13 me escribiste: That's orthogonal. Presumably, json-py is still used for decoding JSON. It does a fine job at that. According to the chanset [370], json-py was removed as a dependency. http://trac.turbogears.org/turbogears/changeset/370 At the moment, TurboGears doesn't actually have anything that depends on incoming JSON (that I'm aware of... CatWalk, perhaps?) You can make REST-style requests just fine without being able to decode JSON. Kevin