Fixed Re: [ZODB-Dev] Help!
JohnD.Heintz
JohnD.Heintz
Thu, 16 Aug 2001 10:53:33 -0500
On Thursday 16 August 2001 07:17, Greg Ward wrote:
> On 15 August 2001, John D . Heintz said:
> > For everyone benifit I've included our HashablePersistent code. Plea=
se
> > let me know if I've messed anything else up, but it seems to be worki=
ng
> > for us.
> >
> > John
> > class HashablePersistent(Persistent):
> > def __hash__(self):
> > """
> > Trivial __hash__ implementation to get identity
> > """
> > if not self._p_oid:
> > someGlobal.ensurePid(self)
> > result =3D hash(self._p_oid)
> > return result
>
> What is ensurePid() -- something of your own devising, or is it lurking
> deep in the bowels of ZODB?
It is our own code. I tried to imply that, but should have said myGlobal=
or=20
something. =20
It resolves to a per session data structure that behaves like=20
CoreSessionTracking. The ensurePid() function adds a temp reference to s=
elf=20
and calls a get_transaction().commit(1) to make sure that the object has =
a=20
_p_oid value.
>
> And shouldn't it really be called ensureOID()?
Probably, but I am really only concerned with the general idea of a=20
persistent id, not the details of _p_oid here. =20
>
> > def __cmp__(self, other):
> > if self._p_oid is None:
> > someGlobal.ensurePid(self)
> >
> > if id(self) =3D=3D id(other):
> > return 0
>
> Usually spelled "if self is other", but maybe that's me.
Your right, thanks. We've made the change.
>
> Greg
>
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
>
> ZODB-Dev mailing list - ZODB-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zodb-dev
--=20
=2E . . . . . . . . . . . . . . . . . . . . . . .
John D. Heintz | Senior Engineer
1016 La Posada Dr. | Suite 240 | Austin TX 78752
T 512.633.1198 | jheintz@isogen.com
w w w . d a t a c h a n n e l . c o m