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

Robert Gravina robert at gravina.com
Fri May 5 06:16:23 MDT 2006


Twisted-list,

In an application I'm writing I would like all Perspective Broker  
clients to share some list of objects and have them all keep in sync  
when one of the clients updates an object's attributes (imagine say a  
shared address book - I'm not creating an address book, but it's  
easier than explaining the details of my app). I've created a  
pb.Cacheable class for the purposes of notifying clients when new  
objects are added to this list which works fine (I based this on the  
cache_classes.py example from the docs here <http://twistedmatrix.com/ 
projects/core/documentation/howto/pb-copyable.html>).

Where I am having trouble is with round trip editing these objects  
(which are all both pb.Copyable and pb.RemoteCopy - I did this so  
that I wouldn't have problems of accidentally storing a RemoteFoo  
object in my ZODB rather than a Foo object). Say one user edits one  
of the objects (e.g. changes the name/phone number etc. of one of the  
entries in the shared address book). and then I callRemote to some  
method like "updateObject" on the users Avatar and pass this object  
to this method. According to the doc page I mentioned previously   
"Copyable objects return unchanged from a round trip", but when I  
check if the object is in the list on the server it thinks it isn't  
there. In fact, they seem to point to different objects in memory, so  
naturally a "if object in list" statement will fail.

Am I checking for equality in the wrong way? Or am I approaching the  
problem in the wrong way?

I am quite new to Twisted, so I apologise if the problem is obvious.

Robert




More information about the Twisted-Python mailing list