Add support for version 2.0 of the JSON-RPC Spec

Bug #456351 reported by Duncan McGreggor
14
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://groups.google.com/group/json-rpc/web/json-rpc-1-2-proposal

People have been asking for txJSON-RPC to support this, so we should do this.

Related branches

Changed in txjsonrpc:
assignee: nobody → Duncan McGreggor (oubiwann)
importance: Undecided → High
Revision history for this message
Duncan McGreggor (oubiwann) wrote :
Download full text (4.4 KiB)

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.
[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://json-rpc.org/wiki/specification says that you're supposed to respond with an object, with 'reply' keys etc.
[07:41] <terrycojones> and v2.0 of the spec says the same.
[07:41] <terrycojones> here's v2.0 http://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.
[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(String('error')) on it.
[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().decodeAsObject(json_str);
[07:52] <terrycojones> if (pyjslib.bool(!(response))) {
[0...

Read more...

Changed in txjsonrpc:
milestone: none → 0.4
Revision history for this message
Jeremy Thurgood (jerith) wrote :

I've linked two branches to this ticket. Together, they should provide v2 support sufficient for most needs.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.