Sorry for digging up this thread but I fell off the list a bit and just checked back today.
I really like the Pyjamas jsonprc implementation. In fact, I like it so much I've gone ahead and modified a few things to do the SMD generation and service URL resolution. However, I have a problem with my approach. This is how I modified JSONRPCServiceBase.__init__: def __init__(self, url): self.methods = {} self.smd = { "serviceType": "JSON-RPC", "serviceURL": url, "methods": [] } Notice that I added the 'url' param and the smd skeleton (no methods yet) I then added the method 'get_smd()' to JSONRPCServiceBase: def get_smd(self): import inspect for method in self.listmethods(): sig = inspect.getargspec(self.methods[method]) self.smd["methods"].append({ "name": method, "parameters": [ {"name": val} for val in sig.args ] }) return simplejson.dumps(self.smd) Then I fixed up JSONRPCService.__call__: def __call__(self, request, extra=None): if request.method == "POST": return HttpResponse(self.process(request), mimetype="application/javascript") else: return HttpResponse(self.get_smd(), mimetype="application/javascript") Use it like so: from jsonrpc import JSONRPCService, jsonremote chatservice = JSONRPCService("/chat/") @jsonremote(chatservice): def send_message(request, message): do something ... Having GET requests return the SMD allows client apps to resolve the methods before calling them so you don't have to use a str-ified version: var chat_service = new dojo.rpc.JsonService("/chat/"); chat_service.send_message("Hello World!").addCallback(function (response) { console.log(response); }); vs: var chat_service = new dojo.rpc.JsonService(); chat_service.serviceUrl = "/chat/"; chat_service.callRemote("send_message", ["Hello World"]).addCallback (function(response) { console.log(response); }); Now the problem ... I can't get URL reversing to work when first setting up the service: from jsonrpc import JSONRPCService, jsonremote chatservice = JSONRPCService( reverse("chat-rpc") ) Urlconf: url(r"^chat/$", "myproj.myapp.views.chatservice", name="chat-rpc", ), ViewDoesNotExist: Tried chatservice in module myproj.myapp.views. Error was: 'module' object has no attribute 'chatservice' But just sticking "/chat/" in there works great. This has to do with when the url is actually reversed -- but I can't figure it out. Any help would be great. Thanks, Ben On Jun 19, 1:17 am, lkcl <luke.leigh...@googlemail.com> wrote: > ok, i added a copy of the code to the wiki page, as some people may > find that easier to access and evaluate rather than from some other > random google group page. > l. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---