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(names, *params)[source]

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

Parameters:
  • names – a list of method names
  • *params – a list of (arg,kwarg) pairs corresponding to each method name
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

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

get_postdata(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

Previous topic

JSON-RPC Server

Next topic

jsonrpc.jsonutil

This Page