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

Robert Gravina robert at gravina.com
Mon Jun 26 13:55:11 EDT 2006

On 2006/06/27, at 1:56, David Bolen wrote:

> Robert Gravina <robert at gravina.com> writes:
>> Ah sorry everyone... it seems I've misunderstood a very basic  
>> concept:
>> Copyables are copy-by-value
>> Referenceables are copy-by-reference
>> It says so here:
>> http://www.lothar.com/tech/papers/PyCon-2003/pb-pycon/pb.html
>> So basically I need to use either Referenceable or Viewable! OK now I
>> can get back to work.
> Well, or just define your own comparison semantics in your copyable,
> as you might for any other object.  We use copyables all the time for
> precisely this pattern (return object remotely, edit it, re-use it in
> a subsequent call back to the server) and it works fine as long as you
> control the comparison and don't fall back to default Python rules,
> which for class instances is effectively just an id() comparison.

Thanks, that is exactly what I am trying to do (return object  
remotely, edit it, re-use it in a subsequent call back to the  
server). What kind of comparison do you do then? Do you compare all  
attributes? By the way, what is an id() comparison? As far as I know  
Python compares to see if the instances (i.e. memory locations) are  

> As it turns out, we do also embed an "_id" attribute within the
> objects (an auto-generated UUID) so we can detect collisions
> (two clients attempting to modify the same object), but for general
> comparison purposes outside of that collision check, we exclude the
> _id attribute.

I've been looking around trying to find some good code for generating  
IDs, but most snippets I can find are accompanied by post after post  
on how that generation technique may fail under certain conditions.

I've been using the ZODB, but for the live of me I can't seem to get  
anything out of the _p_oid attribute (supposedly the object ID, but  
it's always None!). This prompted me today to experiment with Axiom  
(thanks Divmod guys!) and I like what I see so far, but I'm having  
problems with that also (see here if you're interested <http:// 

I'd really like to stick with Copyables and the ZODB if possible.  
What I'm not sure how to do is when I get my copyable back, not screw  
up my references to this object in the ZODB because what I'm really  
getting back is a whole new object.

Thanks for your advice,


> -- David
> _______________________________________________
> 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