JSON-RPC for twisted.web

Dependencies

Background

We needed a twisted-based JSON-RPC server for making remote calls from an AJAX app. This allowed us to change our XML-RPC server to a JSON-RPC server with a simple import change.

Since there is no xmlrpclib equivalent for JSON-RPC, we had to make our own. It's very simple and minimal. We copied error codes and some exception classes from the xmlrpclib in the python standard library, and then we over-rode the simplejson.loads and simplejson.dumps methods with our own module-level functions (basically making a few additions for exception handling).

The original tests from twisted.web.xmlrpc were also included/adapted and pass successfully.

Import

>>> from txjsonrpc.web import jsonrpc

Usage

This is a direct copy from twisted.web.xmlrpc and you use it identically, substituting JSONRPC and jsonrpc everywhere you see XMLRPC and xmlrpc. Here's a link to the docs:

http://twistedmatrix.com/projects/web/documentation/howto/xmlrpc.html

txJSON-RPC/TwistedWeb (last edited 2008-08-06 16:15:37 by localhost)