RpcPython
A qooxdoo JSON-RPC Server in Python.
The RpcPython project provides JSON-RPC backend functionality for web applications using the qooxdoo library ( http://qooxdoo.org ) or simply requiring a JSON-RPC compatible datasource.
RpcPython includes and continues the currently unmaintained qxjsonrpc package (Original Author: Viktor Ferenczi, http://python.cx.hu, see original documentation).
Requirements
1. Python (2.4,2.5, 2.6 should work): The python you use for the qooxdoo toolchain.
2. JSON serializer package. At least one supported package must be installed. Supported packages:
- python-cjson-1.0.3x3 (download from http://python.cx.hu). The current code works only with 1.0.3, will be ported to newer versions.
- simplejson: http://cheeseshop.python.org/pypi/simplejson
- NOTE: python-cjson is MUCH faster, but not pure-python (requires C compiler).
Installation
No installation is necessary, the qxjsonrpc library is shipped with this contrib for easier maintenance and upgrade. A local package is also used so there is no conflict with a site-wide installed qxjsonrpc package.
Usage
- Start the server by "python start-server.py". The server listenes on port 8000. You can configure the port in the start-server.py script.
- The server imports service classes and calls the service methods. It receives a service name in dot-separated path format and expect to find the class containing the service in a file. If the service name is "foo.bar.baz", the class is named "Baz" in the "foo.bar.baz" module, located in "foo/bar/baz.py" somewhere on the python class path.
- The class file is dynamically loaded and the service object instantiated when the request is received (will be done only once for each service object).
- The classes and methods are protected. The service class is only executed if it is a subclass of qxjsonrpc.server.JsonRpcService and if the called method contains the "public" decorator.
Example: qooxdoo client calls
- service: "qooxdoo.test"
- method: "echo"
- params: ["Hello World']
File class/qooxdoo/test.py
from qxjsonrpc import public, fail from qxjsonrpc.server import JsonRpcService class Test( JsonRpcService ): @public def echo(self, v): return 'Client said: [ %s ]'%(v,)
Testing
Use the RpcConsole contrib project as a frontend to test the service classes of your python backend.
Contact
- Viktor Ferenczi <python (at) cx.hu> (Original author of qxjsonrpc)
- Christian Boulanger <info (at) bibliograph.org> (Server wrapper, RpcPython contrib update)