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] 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] terrycojones: hey! [07:37] terrycojones: sorry to hear you're having problems with txJSON-RPC [07:37] hi [07:37] it's being used in production at PBS.org for the tvschedules, so it's working... [07:38] what problems are you having with it? [07:38] the issue i hit was with pyjamas. [07:38] it allows you to make JSONRPC calls, but it expects a JSON object in the reply, not a JSON array. [07:38] did you get it sorted out? [07:38] yes, no problem. [07:38] oh, sweet! [07:39] also it expects a { 'result' : xxxxx } object, and that's not done. maybe i just don't understand it all properly. [07:41] this http://json-rpc.org/wiki/specification says that you're supposed to respond with an object, with 'reply' keys etc. [07:41] and v2.0 of the spec says the same. [07:41] 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] ah, txJSON-RPC was either written before there was a spec or it was written when v1.0 was being bounced around [07:42] ok, that's what i was wondering. there's some stuff in there (like faultMessage or something) that looks pre-spec. [07:42] yup [07:43] never seen the 2.0 proposal (til just now) [07:43] yes, faultString etc in jsonrpclib.py [07:43] anyway, it looks easy to fix, even for me :-) [07:45] I should add this to my TODO list... [07:46] terrycojones: so pyjamas expects JSON-RPC 2.0? [07:46] does it have support for 1.0? [07:48] no, but it expects a JSON object, not an array. [07:49] this: [07:49] if not isinstance(result, jsonrpclib.Fault): [07:49] result = (result,) [07:49] 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] hrm, it seems strange that pyjamas doesn't support the earlier protocol [07:50] 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] 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] it generates this JS, which hits the not-an-object problem: [07:52] response = JSONParser().decodeAsObject(json_str); [07:52] if (pyjslib.bool(!(response))) { [07:52] self.request.handler.onRemoteError(0, String('Server Error or Invalid Response'), (typeof self.request == 'function' && self.__is_instance__?pyjslib.getattr(self, 'request'):self.request)); [07:52] } [07:52] else if (pyjslib.bool((response.has_key(String('error'))) && (response.__getitem__(String('error'))))) { [07:52] error = response.__getitem__(String('error')); [07:52] self.request.handler.onRemoteError(0, error, (typeof self.request == 'function' && self.__is_instance__?pyjslib.getattr(self, 'request'):self.request)); [07:54] anyway, i don't need it fixed in any hurry, i have some stuff working and it sounds like it would break backwards compatibility (at least with PBS.org) unless we put in something to control its results. [07:58] terrycojones: yeah, I'll need to add multi-version support [07:58] (was just looking into that) [07:59] i guess there could be 3 versions: pre-1.0, 1.0, 2.0. [07:59] terrycojones: yeah, my thoughts exactly [07:59] and you get pre-1.0 by default. [07:59] yup [08:00] sounds good.[08:01] i can help, of course. it's not much work.... famous last words.