[ZODB-Dev] Packless and copyTransactionsFrom()????
JohnD.Heintz
JohnD.Heintz
Mon, 20 Aug 2001 18:05:18 -0500
On Monday 20 August 2001 17:31, Jim Fulton wrote:
>
> OTOH, if you tried to create a persistent hash that split keys over
> multiple records based on the has codes, then the stability of the hash
> codes would be an issue.
>
> OTOH, export/import has *copy* semantics. If you try to index (hash or
> BTree) objects based on identity, then operations, like export/import i=
s
> bound to be ... interesting.
>
> If indexing based on identity is important, then it would be a case whe=
re
> database supported (rather than app level) indexes are needed.
>
> Jim
Our application is using indexing based on identify in many places. Our=20
object model is not hierachy/name based like Zope is, and we have lots of=
=20
places where object to object indexes make a lot of sense.
What is the best way to get database supported indexes? Or at least data=
base=20
supported IDs? Twist your arm to make _p_oid application level? We don'=
t=20
need import/export level functionality at the database level because IDs =
are=20
so important to us that we must always deal with them if we were to try a=
nd=20
merge two databases anyway.
Given the export/import semantics described above the following code isn'=
t=20
safe for OOBtrees, right?
class HashablePersistent(Persistent):
=A0 =A0 def __hash__(self):
=A0 =A0 =A0 =A0 """
=A0 =A0 =A0 =A0 Trivial __hash__ implementation to get identity
=A0 =A0 =A0 =A0 """
=A0 =A0 =A0 =A0 if not self._p_oid:
=A0 =A0 =A0 =A0 =A0 =A0 someGlobal.ensurePid(self)
=A0 =A0 =A0 =A0 result =3D hash(self._p_oid)
=A0 =A0 =A0 =A0 return result
=A0 =A0 def __cmp__(self, other):
=A0 =A0 =A0 =A0 if self._p_oid is None:
=A0 =A0 =A0 =A0 =A0 =A0 someGlobal.ensurePid(self)
=A0 =A0 =A0 =A0 if id(self) =3D=3D id(other):
=A0 =A0 =A0 =A0 =A0 =A0 return 0
=A0 =A0 =A0 =A0 if other is None:
=A0 =A0 =A0 =A0 =A0 =A0 return -1
=A0 =A0 =A0 =A0=20
=A0 =A0 =A0 =A0 try:
=A0 =A0 =A0 =A0 =A0 =A0 if other._p_oid is None:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 someGlobal.ensurePid(other)
=A0 =A0 =A0 =A0 =A0 =A0 return cmp(self._p_oid, other._p_oid)
=A0 =A0 =A0 =A0 except AttributeError:
=A0 =A0 =A0 =A0 =A0 =A0 return 1
>
> --
> Jim Fulton mailto:jim@zope.com Python Powered!
> Technical Director (888) 344-4332 http://www.python.org
> Zope Corporation http://www.zope.com http://www.zope.org
--=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