1. Safe Hammad
  2. django-hessian

Source

django-hessian /

Filename Size Date modified Message
djangohessian
19 B
389 B
1.5 KB
1.9 KB
864 B

django-hessian

About

The django-hessian library serves objects via Django using the Hessian RPC protocol.

Requirements

This library requires a version of the mustaine Python Hessian library >=0.1.3 which includes a Hessian WSGI server implementation.

See http://github.com/safehammad/mustaine.

Usage

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:

mysite/myapp/server.py:

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

mysite/urls.py:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
    (r'^rpc/', include('mysite.myapp.urls')),
)

mysite/myapp/urls.py:

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

Documentation

Further documentation can be found at http://safehammad.com/software/django-hessian/.

Source

Up-to-date sources can be found at http://bitbucket.org/safehammad/django-hessian/.