serializable object references

Martin Drautzburg Martin.Drautzburg at web.de
Mon Apr 23 08:35:42 CEST 2007


Gabriel Genellina wrote:

> En Sun, 22 Apr 2007 12:47:10 -0300, Martin Drautzburg
> <Martin.Drautzburg at web.de> escribió:
> 
>> I was thinking that it would be nice if a web application could talk
>> to real objects. The client side does not need to know the internals
>> of an object, it acts as a "view" for server-side models. All it has
>> to be able to do is invoke methods on "its" model. So a view could
>> just store "its" object-reference in an instance variable and pass it
>> to the server, where my problem of looking it up comes in.
> 
> This is more or less what several web frameworks do. You publish
> objects; URLs are mapped to method objects; URL parameters become
> method parameters. See http://wiki.python.org/moin/WebFrameworks
> 

Okay will look. I have checked out cherrypy, but it does not seem to
support direct object references, i.e. the server-side objects are
really stateless and all calls to an object method will see the same
state unless you do something about it youself.

I have also looked at the wonderful qooxdoo javascript framework and in
the examples they have, the data I receive on a published object method
on my cherrypy server is:
dict: {
        '_ScriptTransport_id': '11',
        '_ScriptTransport_data': '{
                "service":"qooxdoo.test",
                "method":"sleep",
                "id":13,
                "params":["10"],
                "server_data":null
        }',
        'nocache': '1177256001914'
}

I am not sure what all of them mean, but my impression is that none of
them denote an object in the sense of an INSTANCE, at least "service"
and "method" definitely do not. The "id" is simply incremented with
every call, so it is again not an instance.

Now I could of course add an object reference do the "params" field and
have qooxdoo.text dispatch the call to an INSTANCE of an object and
invoke sleep() there. But first it is a shame, that I have to provide
this magic myself, and second it raises again my original question: how
to I pass an object reference and look up the object in qooxdoo.test. 

I know I can do this with a dictionary, I just thought that the
__repr__() of an object could be used, as it seems the most obvious way
to do it.



More information about the Python-list mailing list