[Zope3-checkins] CVS: Zope3/src/zodb/storage - bdbminimal.py:1.3

Barry Warsaw barry@wooz.org
Mon, 30 Dec 2002 17:38:53 -0500


Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv754

Modified Files:
	bdbminimal.py 
Log Message:
Rewrite the bsddb imports to use either Python 2.3's bsddb package or
the pybsddb (bsddb3) distutils package, in that order.

DB(): Add this convenience function, a la file.py


=== Zope3/src/zodb/storage/bdbminimal.py 1.2 => 1.3 ===
--- Zope3/src/zodb/storage/bdbminimal.py:1.2	Wed Dec 25 09:12:19 2002
+++ Zope3/src/zodb/storage/bdbminimal.py	Mon Dec 30 17:38:52 2002
@@ -17,10 +17,12 @@
 
 __version__ = '$Revision$'[-2:][0]
 
-# This uses the Dunn/Kuchling PyBSDDB v3 extension module available from
-# http://pybsddb.sourceforge.net.  It is compatible with release 3.4 of
-# PyBSDDB3.
-from bsddb3 import db
+# In Python 2.3, we can simply use the bsddb module, but for Python 2.2, we
+# need to use pybsddb3, a.k.a. bsddb3.
+try:
+    from bsddb import _db as db
+except ImportError:
+    from bsddb3 import db
 
 from zodb import interfaces
 from zodb.utils import p64, u64
@@ -36,6 +38,14 @@
 COMMIT = 'C'
 PRESENT = 'X'
 ZERO = '\0'*8
+
+
+
+def DB(name, config):
+    """Create a new object database using BDBMinimalStorage."""
+    import zodb.db
+    storage = BDBMinimalStorage(name, config=config)
+    return zodb.db.DB(storage)