serializable object references

Martin Drautzburg Martin.Drautzburg at web.de
Sun Apr 22 11:47:10 EDT 2007


Gabriel Genellina wrote:

> En Sun, 22 Apr 2007 08:07:27 -0300, Martin Drautzburg
> <Martin.Drautzburg at web.de> escribió:
> 
>> Is it possible to convert an object into a string that identifies the
>> object in a way, so it can later be looked up by this string.
>> Technically this should be possible, because things like
>>
>> <__main__.Foo instance at 0xb7cfb6ac>
>>
>> say everything about an object. But how can I look up the real
>> object, when I only have this string?
>>
>> I know such a thing can be achieved with a dictionary that holds
>> reference-object pairs. Is there another way?
> 
> Without further information, this would be the way.
> What do you want to achieve? Maybe you are looking for the pickle
> module.
> 

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.

I am currently learning about web services but my feeling is
that "state" is not an integral part of this concept, rather an add-on,
but I may be mistaken here.

But for any reasonable web application you have to introduce state one
way or the other. My impression is, that this is achieved with "session
objects", which hold all the state of a session (again I may be
mistaken). But this would be a strange concept in an OO world. You
might as well put "ALL" state into a global "state" state object, where
all the class methods deposit their state and classes would hold
behavior only and no state. This is of course nothing an OO programmer
would want to do. 







More information about the Python-list mailing list