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

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


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

Modified Files:
	bdbfull.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/bdbfull.py 1.2 => 1.3 ===
--- Zope3/src/zodb/storage/bdbfull.py:1.2	Wed Dec 25 09:12:19 2002
+++ Zope3/src/zodb/storage/bdbfull.py	Mon Dec 30 17:37:59 2002
@@ -21,10 +21,12 @@
 import cPickle as pickle
 from struct import pack, unpack
 
-# This uses the Dunn/Kuchling PyBSDDB v3 extension module available from
-# http://pybsddb.sourceforge.net.  It is compatible with release 3.4 of
-# PyBSDDB3.  The only recommended version of BerkeleyDB is 4.0.14.
-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
@@ -48,6 +50,16 @@
 DNE = '\377'*8
 # DEBUGGING
 #DNE = 'nonexist'
+
+
+
+def DB(name, config):
+    """Create a new object database using BDBFullStorage."""
+    import zodb.db
+    print 'name:', name
+    print config
+    storage = BDBFullStorage(name, config=config)
+    return zodb.db.DB(storage)