[Zope] Questions on ZODB BTrees versus bsddb BTrees
Terry Jones
terry at jon.es
Fri May 5 06:28:07 EDT 2006
>>>>> "Chris" == Chris Withers <chris at simplistix.co.uk> writes:
Chris> Terry Jones wrote:
>> Usually you find database records by means of the record's key.
>> However, the key that you use for your record will not always contain
>> the information required to provide you with rapid access to the data
>> that you want to retrieve.
Chris> Ah, okay, you do this with multiple BTrees in Zope, unless you want
Chris> to swallow the whole ZCatalog...
I think I'll roll my own, at least for now. I don't want to use ZCatalog
for the indexing part, at least not yet. The BaseIndex class in
src/zope/app/catalog/README.txt of the Zope3 SVN tree illustrates pretty
much all I need right now. See, I'm still relying on reading the docs :-)
| >> For example, suppose your database contains
| >> records related to users. The key might be a string that is some unique
| >> identifier for the person, such as a user ID.
|
| Chris> from BTrees.IOBTree import IOBTree
| Chris> chris = object()
|
| Chris> id2user = IOBTree()
| Chris> id2user[1234] = chris
|
| >> is, by the information stored in the key), it may also on occasion want
| >> to location people by, say, their name.
|
| Chris> from BTrees.OOBTree import OOBTree, OOSet
| Chris> name2user = OOBTree()
| Chris> name2user['chris'] = chris
|
| Chris> Now, if you have more than one value, you use a set:
|
| Chris> dan = object()
| Chris> age2user = OOBTree()
| Chris> age2user[27] = OOSet(chris,dan)
Thanks for the code too.
Terry
More information about the Zope
mailing list