On 26 Jun 2006, at 21:28, Robert Gravina wrote:
    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
                return False

and now can compare objects for equality after the (Twisted) client edits them and sends them back.

You can shorten that to
def __eq__(self, other):
    return aq_base(self) is aq_base(other)

Heh, good point.

I assume you're referring to repacing just "isinstance(other, <name of my class>)"? Actually, to be honest I don't even know what Acquisition based classes are, so I'm probably not using them. I'm just subclassing Persistent

No, replacing the whole function. The ZODB ensures that, in a given connection (ie thead usually) peristent objects with the same oid have the same identity (that's the purpose of the "pickle cache" and "_added" cache if you're interested in internals).


Florent Guillaume, Nuxeo (Paris, France)   Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to