[Python-Dev] 3rd-party dbms
Oleg Broytmann
phd at phd.pp.ru
Thu Sep 4 20:59:46 CEST 2008
Brett Cannon <brett at python.org> wrote:
> for 3.1 there is nothing saying we can't change shelve and the
> dbm package to allow 3rd-party code to register with the dbm package
> such that bsddb can be used as needed behind the scenes.
Many years ago I wrote toy hashes based on ZODB and MetaKit. Registering
them with anydbm was easy:
import anydbm
anydbm._names.insert(len(anydbm._names)-1, ['ZODBhash', 'MKhash'])
# Insert before dumbdbm
More complex part was to make whichdb to recognize those hashes. I just
monkey-patched whichdb. If I were doing this now I'd do something similar
to atexit module - every hash module will register its own test function,
and whichdb will call them in turn until it finds which db it is.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-Dev
mailing list