git.fiddlerwoaroof.com
README.markdown
16d1d04a
 A JSON-RPC 2.0 implementation for Python (Python 3 not supported yet)
1a97632a
 
fd975f65
 
8e6716be
 ## Getting Started
295c3dbc
 ### Installing the librarary:
 
     % python setup.py install
 
   Alternatively, one can use the following commands from the directory which contains the 'setup.py' file.
fd975f65
 
4a0b934e
 ### Start the Server:
60df4a1c
 
8e6716be
     % python -m jsonrpc.example_server
     Listening on port 8007...
 
4a0b934e
 ### Start the Client:
1eb8e764
   
b7d14f0c
   Python 2.7: `python -m jsonrpc <host name>`
   
   Python 2.6: `python -m jsonrpc.__main__ <host name>`
fd975f65
 
 
b7d14f0c
     >>> server.add(1, 2)
     3
8e6716be
 
b7d14f0c
     >>> server.subtract(3,2)
     1
fd975f65
 
b7d14f0c
     # Exceptions
     >>> server.add(1, '2')
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "jsonrpc/proxy.py", line 182, in __call__
         raise JSONRPCException(resp['error'])
     jsonrpc.proxy.JSONRPCException: unsupported operand type(s) for +: 'int' and 'unicode'
8e6716be
 
 
03761ad3
     >>> server.batch_call( dict(add=( (1,2), {} ), subtract=( (3,2), {} )) )
     [(3, None), (1, None)] # the pattern is (result, error)
 
     # batch calls can also be done with an iterable, if you want
     # to have more than one call to the same method
     >>> server.batch_call( [('add', ((1, 2), {})), ('subtract', ((3, 2), {}))] )
     [(3, None), (1, None)]
 
     # Exceptions in batch calls
     >>> server.batch_call( dict(add=( (1,2), {} ), subtract=( (3,'2'), {} )) )
     [(3, None), (None, {u'message': u"unsupported operand type(s) for -: 'int' 
       and 'unicode'", u'code': 0, u'data': [u"unsupported operand type(s) for -: 
       'int' and 'unicode'"]})]
8e6716be
 
 
fd975f65
 
1a97632a
 Made for:
     http://ncmi.bcm.edu