[Twisted-Python] can pb.Copyable objects be compared for equality after a round trip?

Robert Gravina robert at gravina.com
Sat Jun 24 13:57:56 EDT 2006

This is an old thread, but I am finally tackling the round trip  
editing problem and unfortunately getting nowhere. Basically, I want  
to be able to create some object on one machine, then send it off to  
another (who edits some of the attributes) then when the other  
machine calls a method on the original machine and passes it the  
updated object, I can identify it simply by comparing for quality.  
Think of your basic client/server database application.

The Twisted howtos make the claim that " Copyable objects return  
unchanged from a round trip", and can be compared for quality like  
(obj == obj) but in all my attempts I can get this to work (they are  
never equal). Does someone know of some sample code where this is  
done successfully? It is done successfully with pb.Referenceables in  
the howtos (look for the pb2client.py and pb2server.py listings).

Since I'm using the ZODB, I've tried using ZODB's _p_oid attribute to  
identify objects that come back to me but the _p_oid is  None even  
after a transaction.commit() (since the object hasn't been persisted  
yet probably).

I could also create my own ID attribute and attempt to generate a  
random ID and compare that, but this is most definately a hack.

I am really having trouble progressing with my application because of  
this problem. I'd really appreciate some insight on how to go about  
solving this. Admittedly I'm not all that experienced with Twisted,  
but I thought this kind of thing was supposed to be straightforward.  
What am I doing wrong?



On 2006/05/07, at 18:55, Micky Latowicki wrote:

> It's possible to make each element in the set being edited a
> cacheable. If you think that would introduce too much overhead, then
> you can add a method to the "address book" object which updates one of
> the entries in this address book, and uses an id to identify the entry
> within the address book. So the address book is the dict. That's what
> I did in a similar case. I'm no expert though.
> Micky
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list