Merge lp:~jerith/txjsonrpc/jsonrpc-2.0-support into lp:txjsonrpc

Proposed by Jeremy Thurgood
Status: Needs review
Proposed branch: lp:~jerith/txjsonrpc/jsonrpc-2.0-support
Merge into: lp:txjsonrpc
Diff against target: 37 lines (+9/-3)
2 files modified
txjsonrpc/jsonrpclib.py (+7/-1)
txjsonrpc/test/test_jsonrpclib.py (+2/-2)
To merge this branch: bzr merge lp:~jerith/txjsonrpc/jsonrpc-2.0-support
Reviewer Review Type Date Requested Status
Duncan McGreggor Pending
Review via email: mp+177605@code.launchpad.net

Description of the change

This builds correctly formatted responses for jsonrpc 2.0 requests.

To post a comment you must log in.
96. By Jeremy Thurgood

Default to v1.0, not the pre-spec behaviour.

Unmerged revisions

96. By Jeremy Thurgood

Default to v1.0, not the pre-spec behaviour.

95. By Jeremy Thurgood

Support v2.0 output.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'txjsonrpc/jsonrpclib.py'
2--- txjsonrpc/jsonrpclib.py 2012-01-28 01:11:15 +0000
3+++ txjsonrpc/jsonrpclib.py 2013-07-30 14:14:25 +0000
4@@ -66,7 +66,13 @@
5 else:
6 result = obj
7 error = None
8- if version == VERSION_PRE1:
9+ if version == VERSION_2:
10+ obj = {"jsonrpc": "2.0", "id": id}
11+ if result:
12+ obj["result"] = result
13+ else:
14+ obj["error"] = error
15+ elif version == VERSION_PRE1:
16 if result:
17 obj = result
18 else:
19
20=== modified file 'txjsonrpc/test/test_jsonrpclib.py'
21--- txjsonrpc/test/test_jsonrpclib.py 2012-01-28 01:11:15 +0000
22+++ txjsonrpc/test/test_jsonrpclib.py 2013-07-30 14:14:25 +0000
23@@ -52,14 +52,14 @@
24 result = dumps(object, version=VERSION_2)
25 self.assertEquals(
26 result,
27- '{"id": null, "result": {"some": "data"}, "error": null}')
28+ '{"jsonrpc": "2.0", "id": null, "result": {"some": "data"}}')
29
30 def test_errorVersion2(self):
31 object = Fault("code", "message")
32 result = dumps(object, version=VERSION_2)
33 self.assertEquals(
34 result,
35- ('{"id": null, "result": null, "error": {"fault": "Fault", '
36+ ('{"jsonrpc": "2.0", "id": null, "error": {"fault": "Fault", '
37 '"faultCode": "code", "faultString": "message"}}'))
38
39

Subscribers

People subscribed via source and target branches

to all changes: