Fixed Re: [ZODB-Dev] Help!

Greg Ward gward@mems-exchange.org
Thu, 16 Aug 2001 08:17:26 -0400


On 15 August 2001, John D . Heintz said:
> For everyone benifit I've included our HashablePersistent code.  Please let 
> me know if I've messed anything else up, but it seems to be working for us.
> 
> John
> class HashablePersistent(Persistent):
>     def __hash__(self):
>         """
>         Trivial __hash__ implementation to get identity
>         """
>         if not self._p_oid:
>             someGlobal.ensurePid(self)
>         result = hash(self._p_oid)
>         return result

What is ensurePid() -- something of your own devising, or is it lurking
deep in the bowels of ZODB?

And shouldn't it really be called ensureOID()?

>     def __cmp__(self, other):
>         if self._p_oid is None:
>             someGlobal.ensurePid(self)
> 
>         if id(self) == id(other):
>             return 0

Usually spelled "if self is other", but maybe that's me.

        Greg