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
            else:
                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

--
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:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to