Add support for version 2.0 of the JSON-RPC Spec
Bug #456351 reported by
Duncan McGreggor
This bug affects 3 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
txJSON-RPC |
New
|
High
|
Duncan McGreggor |
Bug Description
The JSON-RPC 2.0 spec has been proposed here:
http://
People have been asking for txJSON-RPC to support this, so we should do this.
Related branches
lp://staging/~jerith/txjsonrpc/add-id-to-response
Ready for review
for merging
into
lp://staging/txjsonrpc
- Duncan McGreggor: Pending requested
-
Diff: 181 lines (+42/-17)5 files modifiedtxjsonrpc/jsonrpc.py (+13/-7)
txjsonrpc/netstring/jsonrpc.py (+2/-1)
txjsonrpc/test/test_jsonrpc.py (+3/-3)
txjsonrpc/web/jsonrpc.py (+7/-6)
txjsonrpc/web/test/test_jsonrpc.py (+17/-0)
lp://staging/~jerith/txjsonrpc/jsonrpc-2.0-support
Ready for review
for merging
into
lp://staging/txjsonrpc
- Duncan McGreggor: Pending requested
-
Diff: 37 lines (+9/-3)2 files modifiedtxjsonrpc/jsonrpclib.py (+7/-1)
txjsonrpc/test/test_jsonrpclib.py (+2/-2)
Changed in txjsonrpc: | |
assignee: | nobody → Duncan McGreggor (oubiwann) |
importance: | Undecided → High |
Changed in txjsonrpc: | |
milestone: | none → 0.4 |
To post a comment you must log in.
The impetus for v2.0 spec support came from Terry Jones as a result of some pyjamas work he was doing. Here's the IRC chat we had:
[04:17] <terrycojones> i've been taking a look at txjsonrpc and it seems in need of a bit of love & care. i'm trying to use it with pyjamas and had to dig in a little to find out why things weren't working. anyway, i was thinking of submitting a patch, but i don't know enough to know whether i'm really doing the right thing or not. json-rpc. org/wiki/ specification says that you're supposed to respond with an object, with 'reply' keys etc. groups. google. com/group/ json-rpc/ web/json- rpc-1-2- proposal but i expect you've seen all this and that i'm not understanding something basic. String( 'error' )) on it. ).decodeAsObjec t(json_ str); bool(!( response) )) {
[07:37] <oubiwann> terrycojones: hey!
[07:37] <oubiwann> terrycojones: sorry to hear you're having problems with txJSON-RPC
[07:37] <terrycojones> hi
[07:37] <oubiwann> it's being used in production at PBS.org for the tvschedules, so it's working...
[07:38] <oubiwann> what problems are you having with it?
[07:38] <terrycojones> the issue i hit was with pyjamas.
[07:38] <terrycojones> it allows you to make JSONRPC calls, but it expects a JSON object in the reply, not a JSON array.
[07:38] <oubiwann> did you get it sorted out?
[07:38] <terrycojones> yes, no problem.
[07:38] <oubiwann> oh, sweet!
[07:39] <terrycojones> also it expects a { 'result' : xxxxx } object, and that's not done. maybe i just don't understand it all properly.
[07:41] <terrycojones> this http://
[07:41] <terrycojones> and v2.0 of the spec says the same.
[07:41] <terrycojones> here's v2.0 http://
[07:41] <oubiwann> ah, txJSON-RPC was either written before there was a spec or it was written when v1.0 was being bounced around
[07:42] <terrycojones> ok, that's what i was wondering. there's some stuff in there (like faultMessage or something) that looks pre-spec.
[07:42] <oubiwann> yup
[07:43] <oubiwann> never seen the 2.0 proposal (til just now)
[07:43] <terrycojones> yes, faultString etc in jsonrpclib.py
[07:43] <terrycojones> anyway, it looks easy to fix, even for me :-)
[07:45] <oubiwann> I should add this to my TODO list...
[07:46] <oubiwann> terrycojones: so pyjamas expects JSON-RPC 2.0?
[07:46] <oubiwann> does it have support for 1.0?
[07:48] <terrycojones> no, but it expects a JSON object, not an array.
[07:49] <terrycojones> this:
[07:49] <terrycojones> if not isinstance(result, jsonrpclib.Fault):
[07:49] <terrycojones> result = (result,)
[07:49] <terrycojones> results in an array being sent back. then pyjamas falls over because it tries to do a has_key(
[07:50] <oubiwann> hrm, it seems strange that pyjamas doesn't support the earlier protocol
[07:50] <terrycojones> and it's also expecting a 'result' key in there, etc. i can put one in myself, but it seems like that should be the job of the lib.
[07:51] <terrycojones> it may do in some way, i only started looking at it last night, so i'm only able to say what it does by default.
[07:52] <terrycojones> it generates this JS, which hits the not-an-object problem:
[07:52] <terrycojones> response = JSONParser(
[07:52] <terrycojones> if (pyjslib.
[0...