X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/python-jsonrpclib.git/blobdiff_plain/6a388ded772221c4b5fbb07ed69db8d57b0b583e..a8ad7ff0ea1fd16957abf3132159b88fb9f5d889:/README.md diff --git a/README.md b/README.md index 8ba8425..9d431a4 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,6 @@ Client Usage This is (obviously) taken from a console session. - >>> import jsonrpclib >>> server = jsonrpclib.Server('http://localhost:8080') >>> server.add(5,6) @@ -70,13 +69,11 @@ This is (obviously) taken from a console session. 11 {'key': 'value'} # Note that there are only two responses -- this is according to spec. - If you need 1.0 functionality, there are a bunch of places you can pass that in, although the best is just to change the value on jsonrpclib.config.version: - >>> import jsonrpclib >>> jsonrpclib.config.version 2.0 @@ -89,7 +86,6 @@ jsonrpclib.config.version: >>> print jsonrpclib.history.response {'id': 'thes7tl2', 'result': 17, 'error': None} >>> - The equivalent loads and dumps functions also exist, although with minor modifications. The dumps arguments are almost identical, but it adds three @@ -105,7 +101,6 @@ SimpleJSONRPCServer ------------------- This is identical in usage (or should be) to the SimpleXMLRPCServer in the default Python install. Some of the differences in features are that it obviously supports notification, batch calls, class translation (if left on), etc. Note: The import line is slightly different from the regular SimpleXMLRPCServer, since the SimpleJSONRPCServer is distributed within the jsonrpclib library. - from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer server = SimpleJSONRPCServer(('localhost', 8080)) @@ -113,7 +108,6 @@ This is identical in usage (or should be) to the SimpleXMLRPCServer in the defau server.register_function(lambda x,y: x+y, 'add') server.register_function(lambda x: x, 'ping') server.serve_forever() - Class Translation ----------------- @@ -137,7 +131,6 @@ behavior recursively goes through attributes and lists / dicts / tuples). [test_obj.py] - # This object is /very/ simple, and the system will look through the # attributes and serialize what it can. class TestObj(object): @@ -152,11 +145,9 @@ behavior recursively goes through attributes and lists / dicts / tuples). self.args = args def _serialize(self): return (self.args, {'foo':self.foo,}) - [usage] - import jsonrpclib import test_obj @@ -172,7 +163,6 @@ behavior recursively goes through attributes and lists / dicts / tuples). # {"jsonrpc": "2.0", "params": [{"__jsonclass__": ["test_obj.TestSerial", ["foo"]]}], "id": "a0l976iv", "method": "ping"} print jsonrpclib.history.result # {'jsonrpc': '2.0', 'result': , 'id': 'a0l976iv'} - To turn on this behaviour, just set jsonrpclib.config.use_jsonclass to True. If you want to use a different method for serialization, just set