As of this writing (in Jan 2013) there are a few jsonrpc libraries already out there on PyPI, most of them handling one specific use case (i.e. json via WSGI, using Twisted, or TCP-sockets).
None of the libraries, however, made it easy to reuse the jsonrpc-parsing bits and substitute a different transport (i.e. going from json via TCP to an implementation using WebSockets or 0mq).
In the end, all these libraries have their own dispatching interfaces and a custom implementation of handling jsonrpc.
tinyrpc
aims to do better by dividing the problem into cleanly
interchangeable parts that allow easy addition of new transport methods, RPC
protocols or dispatchers.
tinyrpc
architectually considers three layers: Transport, Protocol and
Dispatch.
The Transport-layer is responsible for receiving and sending messages. No assumptions are made about messages, except that they are of a fixed size. Messages are received and possibly passed on a Python strings.
On the Protocol-layer messages are decoded into a format that is protocol independent, these can be passed on to a dispatcher.
The Dispatch-layer performs the actual method calling and serializes the return value. These can be routed back through the Protocol- and Transport-layer to return the answer to the calling client.
Each layer is useful "on its own" and can be used seperately. If you simply
need to decode a jsonrpc message, without passing it on or sending it through
a transport, the JSONRPCProtocol
-class is completely usable on its own.
Currently, only jsonrpc is supported[#]_.