A user has requested that RPC4Django support HTTP access control. This is the new preferred method where newer browsers are allowed to make cross domain AJAX requests (with specific constraints) without having to resort to hacks and workarounds like dynamic script tags. I also want to work on JSON class hinting, which is not currently supported. I’m shooting to get this going in the next week before I leave for a Mexican vacation. Swine flu has made the Mexican resorts very reasonable.
Weird Issue on Chrome
In addition, I have noticed that the authenticated demo site does not work in Google Chrome. Is anyone else experiencing this? Any idea why? There’s no problem with Chrome on the demo site not running ssl.
The first version of my unified xmlrpc and jsonrpc server is available. Go get it!
After looking around at the rpc support available in Django, I think I will create and distribute my own application. Here are the goals:
- Complete xml and json rpc support
- Easy identification of rpc methods by a decorator
- Customizable documentation (which is absent from DocXMLRPCServer)
- Support rpc introspection
- Support for method signatures (which is absent from SimpleXMLRPCServer)
- Easy installation and integration into Django projects
- Licensed properly for open source or commercial software
Updates to come. I’m off to San Francisco for a weekend of fun.
[Edit: take a look at RPC4Django for a JSONRPC and XMLRPC server for Django]
I corresponded recently with a developer working on a Django-powered jsonrpc library. In the past, I have done some work on web applications that require good external interfaces. In some cases, however, it makes sense to make the same methods available via both jsonrpc and xmlrpc.
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
from django.http import HttpResponse, Http404
from jsonrpc import JsonRpc
xmlrpcdispatcher = SimpleXMLRPCDispatcher(allow_none=False, encoding=None)
jsonrpcdispatcher = JsonRpc()
# ... register methods with xmlrpc and jsonrpc
if request.META['CONTENT_TYPE'] == 'application/json':
response = jsonrpcdispatcher.handle_request(request)
elif request.META['CONTENT_TYPE'] == 'text/xml':
response = HttpResponse()
response['Content-length'] = str(len(response.content))
# display documentation, or just raise a 404
logging.debug('rpc request type: %s' %request.META['CONTENT_TYPE'])