[Grok-dev] Example JSON-RPC example

Roger Erens roger.erens at e-s-c.biz
Fri Apr 3 03:45:35 EDT 2009


on 04/02/2009 12:06 PM Souheil CHELFOUH wrote:
> A very simple example here :
> http://tracker.trollfot.org/browser/projects/dolmen/dolmen.packages/menhir.simple.navtree/menhir/simple/navtree/base.py

Thanks Souheil,

but I still have some problems understanding the JSON-RPC story. I
understand that methods in a JSON class result in views. That is, when
the method does not start with an underscore.

But I don't really understand how to call/invoke/process the view.

Let's say I followed the Grok Tutorial and have added this class to app.py:

class SampleJson(grok.JSON):
    grok.context(Sample)

    def reverse(self, msg):
        return msg[::-1]

Then, after having created a sample application, when I enter the URL
http://localhost:8080/sample/reverse?msg=Hello

the browser shows a page
"olleH"

But shouldn't I be able to only receive this piece of data in
JSON-format and incorporate it into a web page? I don't get this piece
of the puzzle. It appears to involve requests that have the content type
application/x-www-form-urlencoded or application/json?

I browsed a little around in your dolmen project, but I did not find how
your jsonrpc class is *used*.

Background information: I am trying to see if pyjamas (www.pyjs.org) can
be used in conjunction with Grok. It is supposed to generate javascript
AJAX-widgets from python.

I'd appreciate if someone could help me a little further on track.

Best,

Roger


More information about the Grok-dev mailing list