[ZODB-Dev] Re: getting the object ID (_p_oid attribute)
Gary Poster
gary at zope.com
Mon Jun 26 15:16:35 EDT 2006
On Jun 26, 2006, at 3:11 PM, Robert Gravina wrote:
> I seemed to have solved this problem. I was able to write a __eq__
> function like this:
>
> def __eq__(self, other):
> if isinstance(other, <name of my class>):
> if hasattr(other,"_p_oid") and other._p_oid != None and
> (other._p_oid == self._p_oid):
> return True
> else:
> return False
>
> and now can compare objects for equality after the (Twisted) client
> edits them and sends them back.
To be *really* careful in the face of multi-databases, you'd check
database names too. See the zope.app.keyreference.persistent code,
for instance.
If you don't have multidatabases, then this code looks like it will
do the job.
Gary
More information about the ZODB-Dev
mailing list