[Zope] Mixing keys

Dieter Maurer dieter at handshake.de
Fri Oct 31 16:49:26 EST 2003


Harm_Kirchhoff at mail.digital.co.jp wrote at 2003-10-31 17:41 +0900:
 > I am new to ZOPE, so maybe this question is too simple:
 > 
 > I would like to use a BTRee (OOBTree) to store information.
 > For one type of sub-branch, I would like to use a continuous series of 
 > integers as keys:
 > 
 > dbroot['SE_HMI']={ '2003' : { 'jrl' : { 0 : <a tuple of data>}} 
 > dbroot['SE_HMI']={ '2003' : { 'jrl' : { 1 : <a tuple of data>}}
 > dbroot['SE_HMI']={ '2003' : { 'jrl' : { 2 : <a tuple of data>}} 
 > ... and so on ...
 > 
 > all other branches besides 'jrl' will have string keys.
 > 
 > I read in the ZODB,ZEO programming guide (www.zope.org/Wikis/ZODB/guide/)
 > that you should only use objects of a SINGLE type as keys.

Mixing keys may no longer be a problem for Python 2.3.
Python 2.3 compares objects of different types first by type name
and then by id. This is a persistent order and could be used
in BTrees.

However, Python does not specify ordering. Later Python version
may change the ordering and this would corrupt your BTrees.

-- 
Dieter



More information about the Zope mailing list