JSON-RPC Proxy

class jsonrpc.proxy.JSONRPCProxy(host, path='jsonrpc', serviceName=None, *args, **kwargs)[source]

A class implementing a JSON-RPC Proxy.

Parameters:
  • host (str) – The HTTP server hosting the JSON-RPC server
  • path (str) – The path where the JSON-RPC server can be found

There are two ways of instantiating this class: - JSONRPCProxy.from_url(url) – give the absolute url to the JSON-RPC server - JSONRPC(host, path) – break up the url into smaller parts

batch_call(methods)[source]

call several methods at once, return a list of (result, error) pairs

Parameters:names – a dictionary { method: (args, kwargs) }
Returns:a list of pairs (result, error) where only one is not None
call(method, *args, **kwargs)[source]

call a JSON-RPC method

It’s better to use instance.<methodname>(*args, **kwargs), but this version might be useful occasionally

classmethod from_url(url, ctxid=None, serviceName=None)[source]

Create a JSONRPCProxy from a URL

class jsonrpc.proxy.ProxyEvents(proxy)[source]

An event handler for JSONRPCProxy

Allow a subclass to do its own initialization, gets any arguments leftover from __init__

IDGen = 'ca6bcd74f0eecfc3e3aba6f25c5b62df9566edfc'

an instance of a class which defines a __get__ method, used to generate a request id

get_params(args, kwargs)[source]

allow a subclass to modify the method’s arguments

e.g. if an authentication token is necessary, the subclass can automatically insert it into every call

proc_response(data)[source]

allow a subclass to access the response data before it is returned to the user