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

Robert Gravina robert at gravina.com
Mon Jun 26 15:18:03 EDT 2006

Thanks Mike and others.. I just figured out how I can get this to  
work (with a bit of help from the ZODB mailing list too)! I am using  
the ZODB, and up until now I though that the _p_oid (the attribute  
that stores a unique object ID) was None all the time, even after I  
had persisted an object. I tried loading up a persisted object  
iteractively and found:

 >>> p._p_oid
 >>> print p._p_oid
 >>> p._p_oid is None

... that it prints out as nothing, but it really is something (hence  
missing it in all my debug printouts)! (Those nutcase Zope  
developers!)... anyhow, it now appears I can compare the _p_oid of a  
Copyable coming back and find the object that represents it on the  
server, update it accordingly, commit the transaction and do a  
victory dance.

Thanks all for you help.

I thought I'd post this so anyone else using Twisted and ZODB won't  
spend days on this like I did.


On 2006/06/27, at 3:55, Mike Pelletier wrote:

> On Monday 26 June 2006 13:55, Robert Gravina wrote:
>> 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
>> equal.
> You got your chocolate in my peanutbutter!
> An "id()" comparison would be, "id(this) == id(that)".  In most (all?)
> implementations, 'id()' returns the memory location, but this is an
> implementation detail that is not guaranteed and shouldn't be  
> depended on.
> An object's python id is to be treated as an opaque identifier.
> Mike.

More information about the Twisted-Python mailing list