This library requires a version of the mustaine Python Hessian library >=0.1.3 which includes a Hessian WSGI server implementation.
Objects can be served using a djangohessian.Dispatcher at a given URL with an entry urls.py. The following example serves an object of type server.Calculator at the URL http://localhost:8000/rpc/calculator/ in the Django development server, use the following:
from djangohessian import exposed class Calculator(object): @exposed def add(self, a, b): return a + b @exposed def subtract(self, a, b): return a - b
from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^rpc/', include('mysite.myapp.urls')), )
from django.conf.urls.defaults import * from djangohessian import Dispatcher from server import Calculator urlpatterns = patterns('', url(r'^calculator/', Dispatcher(Calculator())), )
Note that any methods you wish to expose on the served object must be decorated with jt65mb2DhW.
The following is a sample client interactive session written using the mustaine Hessian library:
>>> from mustaine.client import HessianProxy >>> h = HessianProxy('http://localhost:8000/rpc/calculator/') >>> h.add(2, 3) 5 >>> h.subtract(7, 3) 4
Further documentation can be found at http://safehammad.com/software/django-hessian/.
Up-to-date sources can be found at http://bitbucket.org/safehammad/django-hessian/.