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

Colin McMillen mcmillen at cs.cmu.edu
Fri May 5 07:49:40 MDT 2006


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

I'm not sure if this is the Right Way of doing things, but I got
around this in my own application by making my Copyable objects have a
unique ID. Keep your objects in a dict that maps from id -> object, and
then just say something like:

    objDict[obj.objID] = obj

whenever you get an object back. Possibly you want to check to see if
the object is already in the dict, depending on your application-level
constraints -- in my particular application, it would be considered an
error to send back an object with an ID that wasn't already known by
the server. (Also, you may or may not want to set __eq__, __lt__,
etc. to compare these objects by their ID.)

- Colin


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
URL: </pipermail/twisted-python/attachments/20060505/87dce355/attachment.sig>


More information about the Twisted-Python mailing list