mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Everything worked in both the distutils distro and in Python 2.3cvs,
so merge from the bsddb-bsddb3-schizo-branch back to the trunk.
This commit is contained in:
		
							parent
							
								
									a6ae9a2128
								
							
						
					
					
						commit
						f71de3e9a0
					
				
					 18 changed files with 213 additions and 119 deletions
				
			
		| 
						 | 
					@ -44,11 +44,11 @@
 | 
				
			||||||
    del sys.modules[__name__]
 | 
					    del sys.modules[__name__]
 | 
				
			||||||
    raise
 | 
					    raise
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
# bsddb3 calls it _db
 | 
					# bsddb3 calls it db, but provide _db for backwards compatibility
 | 
				
			||||||
_db = _bsddb
 | 
					db = _db = _bsddb
 | 
				
			||||||
__version__ = _db.__version__
 | 
					__version__ = db.__version__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
error = _db.DBError  # So bsddb.error will mean something...
 | 
					error = db.DBError  # So bsddb.error will mean something...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -152,14 +152,14 @@ def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None,
 | 
				
			||||||
            cachesize=None, lorder=None, hflags=0):
 | 
					            cachesize=None, lorder=None, hflags=0):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    flags = _checkflag(flag)
 | 
					    flags = _checkflag(flag)
 | 
				
			||||||
    d = _db.DB()
 | 
					    d = db.DB()
 | 
				
			||||||
    d.set_flags(hflags)
 | 
					    d.set_flags(hflags)
 | 
				
			||||||
    if cachesize is not None: d.set_cachesize(0, cachesize)
 | 
					    if cachesize is not None: d.set_cachesize(0, cachesize)
 | 
				
			||||||
    if pgsize is not None:    d.set_pagesize(pgsize)
 | 
					    if pgsize is not None:    d.set_pagesize(pgsize)
 | 
				
			||||||
    if lorder is not None:    d.set_lorder(lorder)
 | 
					    if lorder is not None:    d.set_lorder(lorder)
 | 
				
			||||||
    if ffactor is not None:   d.set_h_ffactor(ffactor)
 | 
					    if ffactor is not None:   d.set_h_ffactor(ffactor)
 | 
				
			||||||
    if nelem is not None:     d.set_h_nelem(nelem)
 | 
					    if nelem is not None:     d.set_h_nelem(nelem)
 | 
				
			||||||
    d.open(file, _db.DB_HASH, flags, mode)
 | 
					    d.open(file, db.DB_HASH, flags, mode)
 | 
				
			||||||
    return _DBWithCursor(d)
 | 
					    return _DBWithCursor(d)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
| 
						 | 
					@ -169,14 +169,14 @@ def btopen(file, flag='c', mode=0666,
 | 
				
			||||||
            pgsize=None, lorder=None):
 | 
					            pgsize=None, lorder=None):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    flags = _checkflag(flag)
 | 
					    flags = _checkflag(flag)
 | 
				
			||||||
    d = _db.DB()
 | 
					    d = db.DB()
 | 
				
			||||||
    if cachesize is not None: d.set_cachesize(0, cachesize)
 | 
					    if cachesize is not None: d.set_cachesize(0, cachesize)
 | 
				
			||||||
    if pgsize is not None: d.set_pagesize(pgsize)
 | 
					    if pgsize is not None: d.set_pagesize(pgsize)
 | 
				
			||||||
    if lorder is not None: d.set_lorder(lorder)
 | 
					    if lorder is not None: d.set_lorder(lorder)
 | 
				
			||||||
    d.set_flags(btflags)
 | 
					    d.set_flags(btflags)
 | 
				
			||||||
    if minkeypage is not None: d.set_bt_minkey(minkeypage)
 | 
					    if minkeypage is not None: d.set_bt_minkey(minkeypage)
 | 
				
			||||||
    if maxkeypage is not None: d.set_bt_maxkey(maxkeypage)
 | 
					    if maxkeypage is not None: d.set_bt_maxkey(maxkeypage)
 | 
				
			||||||
    d.open(file, _db.DB_BTREE, flags, mode)
 | 
					    d.open(file, db.DB_BTREE, flags, mode)
 | 
				
			||||||
    return _DBWithCursor(d)
 | 
					    return _DBWithCursor(d)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
| 
						 | 
					@ -187,7 +187,7 @@ def rnopen(file, flag='c', mode=0666,
 | 
				
			||||||
            rlen=None, delim=None, source=None, pad=None):
 | 
					            rlen=None, delim=None, source=None, pad=None):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    flags = _checkflag(flag)
 | 
					    flags = _checkflag(flag)
 | 
				
			||||||
    d = _db.DB()
 | 
					    d = db.DB()
 | 
				
			||||||
    if cachesize is not None: d.set_cachesize(0, cachesize)
 | 
					    if cachesize is not None: d.set_cachesize(0, cachesize)
 | 
				
			||||||
    if pgsize is not None: d.set_pagesize(pgsize)
 | 
					    if pgsize is not None: d.set_pagesize(pgsize)
 | 
				
			||||||
    if lorder is not None: d.set_lorder(lorder)
 | 
					    if lorder is not None: d.set_lorder(lorder)
 | 
				
			||||||
| 
						 | 
					@ -196,7 +196,7 @@ def rnopen(file, flag='c', mode=0666,
 | 
				
			||||||
    if rlen is not None: d.set_re_len(rlen)
 | 
					    if rlen is not None: d.set_re_len(rlen)
 | 
				
			||||||
    if source is not None: d.set_re_source(source)
 | 
					    if source is not None: d.set_re_source(source)
 | 
				
			||||||
    if pad is not None: d.set_re_pad(pad)
 | 
					    if pad is not None: d.set_re_pad(pad)
 | 
				
			||||||
    d.open(file, _db.DB_RECNO, flags, mode)
 | 
					    d.open(file, db.DB_RECNO, flags, mode)
 | 
				
			||||||
    return _DBWithCursor(d)
 | 
					    return _DBWithCursor(d)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
| 
						 | 
					@ -204,18 +204,18 @@ def rnopen(file, flag='c', mode=0666,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def _checkflag(flag):
 | 
					def _checkflag(flag):
 | 
				
			||||||
    if flag == 'r':
 | 
					    if flag == 'r':
 | 
				
			||||||
        flags = _db.DB_RDONLY
 | 
					        flags = db.DB_RDONLY
 | 
				
			||||||
    elif flag == 'rw':
 | 
					    elif flag == 'rw':
 | 
				
			||||||
        flags = 0
 | 
					        flags = 0
 | 
				
			||||||
    elif flag == 'w':
 | 
					    elif flag == 'w':
 | 
				
			||||||
        flags =  _db.DB_CREATE
 | 
					        flags =  db.DB_CREATE
 | 
				
			||||||
    elif flag == 'c':
 | 
					    elif flag == 'c':
 | 
				
			||||||
        flags =  _db.DB_CREATE
 | 
					        flags =  db.DB_CREATE
 | 
				
			||||||
    elif flag == 'n':
 | 
					    elif flag == 'n':
 | 
				
			||||||
        flags = _db.DB_CREATE | _db.DB_TRUNCATE
 | 
					        flags = db.DB_CREATE | db.DB_TRUNCATE
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        raise error, "flags should be one of 'r', 'w', 'c' or 'n'"
 | 
					        raise error, "flags should be one of 'r', 'w', 'c' or 'n'"
 | 
				
			||||||
    return flags | _db.DB_THREAD
 | 
					    return flags | db.DB_THREAD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -231,7 +231,7 @@ def _checkflag(flag):
 | 
				
			||||||
    import thread
 | 
					    import thread
 | 
				
			||||||
    del thread
 | 
					    del thread
 | 
				
			||||||
except ImportError:
 | 
					except ImportError:
 | 
				
			||||||
    _db.DB_THREAD = 0
 | 
					    db.DB_THREAD = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,12 @@
 | 
				
			||||||
#------------------------------------------------------------------------
 | 
					#------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cPickle
 | 
					import cPickle
 | 
				
			||||||
from bsddb import db
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#------------------------------------------------------------------------
 | 
					#------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,23 +17,26 @@
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
_cvsid = '$Id$'
 | 
					_cvsid = '$Id$'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import string
 | 
					 | 
				
			||||||
import sys
 | 
					 | 
				
			||||||
try:
 | 
					 | 
				
			||||||
    import cPickle
 | 
					 | 
				
			||||||
    pickle = cPickle
 | 
					 | 
				
			||||||
except ImportError:
 | 
					 | 
				
			||||||
    import pickle
 | 
					 | 
				
			||||||
import whrandom
 | 
					 | 
				
			||||||
import xdrlib
 | 
					 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
import copy
 | 
					import copy
 | 
				
			||||||
 | 
					import xdrlib
 | 
				
			||||||
 | 
					import whrandom
 | 
				
			||||||
 | 
					from types import ListType, StringType
 | 
				
			||||||
 | 
					import cPickle as pickle
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb.db import *
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb.db import *
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3.db import *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TableDBError(StandardError): pass
 | 
					class TableDBError(StandardError):
 | 
				
			||||||
class TableAlreadyExists(TableDBError): pass
 | 
					    pass
 | 
				
			||||||
 | 
					class TableAlreadyExists(TableDBError):
 | 
				
			||||||
 | 
					    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Cond:
 | 
					class Cond:
 | 
				
			||||||
| 
						 | 
					@ -72,9 +75,9 @@ def __init__(self, likestr, re_flags=re.IGNORECASE):
 | 
				
			||||||
        # escape python re characters
 | 
					        # escape python re characters
 | 
				
			||||||
        chars_to_escape = '.*+()[]?'
 | 
					        chars_to_escape = '.*+()[]?'
 | 
				
			||||||
        for char in chars_to_escape :
 | 
					        for char in chars_to_escape :
 | 
				
			||||||
            likestr = string.replace(likestr, char, '\\'+char)
 | 
					            likestr = likestr.replace(char, '\\'+char)
 | 
				
			||||||
        # convert %s to wildcards
 | 
					        # convert %s to wildcards
 | 
				
			||||||
        self.likestr = string.replace(likestr, '%', '.*')
 | 
					        self.likestr = likestr.replace('%', '.*')
 | 
				
			||||||
        self.re = re.compile('^'+self.likestr+'$', re_flags)
 | 
					        self.re = re.compile('^'+self.likestr+'$', re_flags)
 | 
				
			||||||
    def __call__(self, s):
 | 
					    def __call__(self, s):
 | 
				
			||||||
        return self.re.match(s)
 | 
					        return self.re.match(s)
 | 
				
			||||||
| 
						 | 
					@ -84,7 +87,9 @@ def __call__(self, s):
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
_table_names_key = '__TABLE_NAMES__'  # list of the tables in this db
 | 
					_table_names_key = '__TABLE_NAMES__'  # list of the tables in this db
 | 
				
			||||||
_columns = '._COLUMNS__'  # table_name+this key contains a list of columns
 | 
					_columns = '._COLUMNS__'  # table_name+this key contains a list of columns
 | 
				
			||||||
def _columns_key(table) : return table + _columns
 | 
					
 | 
				
			||||||
 | 
					def _columns_key(table):
 | 
				
			||||||
 | 
					    return table + _columns
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# these keys are found within table sub databases
 | 
					# these keys are found within table sub databases
 | 
				
			||||||
| 
						 | 
					@ -93,28 +98,39 @@ def _columns_key(table) : return table + _columns
 | 
				
			||||||
_rowid = '._ROWID_.' # this+rowid+this key contains a unique entry for each
 | 
					_rowid = '._ROWID_.' # this+rowid+this key contains a unique entry for each
 | 
				
			||||||
                     # row in the table.  (no data is stored)
 | 
					                     # row in the table.  (no data is stored)
 | 
				
			||||||
_rowid_str_len = 8   # length in bytes of the unique rowid strings
 | 
					_rowid_str_len = 8   # length in bytes of the unique rowid strings
 | 
				
			||||||
def _data_key(table, col, rowid) : return table + _data + col + _data + rowid
 | 
					
 | 
				
			||||||
def _search_col_data_key(table, col) : return table + _data + col + _data
 | 
					def _data_key(table, col, rowid):
 | 
				
			||||||
def _search_all_data_key(table) : return table + _data
 | 
					    return table + _data + col + _data + rowid
 | 
				
			||||||
def _rowid_key(table, rowid) : return table + _rowid + rowid + _rowid
 | 
					
 | 
				
			||||||
def _search_rowid_key(table) : return table + _rowid
 | 
					def _search_col_data_key(table, col):
 | 
				
			||||||
 | 
					    return table + _data + col + _data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def _search_all_data_key(table):
 | 
				
			||||||
 | 
					    return table + _data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def _rowid_key(table, rowid):
 | 
				
			||||||
 | 
					    return table + _rowid + rowid + _rowid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def _search_rowid_key(table):
 | 
				
			||||||
 | 
					    return table + _rowid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def contains_metastrings(s) :
 | 
					def contains_metastrings(s) :
 | 
				
			||||||
    """Verify that the given string does not contain any
 | 
					    """Verify that the given string does not contain any
 | 
				
			||||||
    metadata strings that might interfere with dbtables database operation.
 | 
					    metadata strings that might interfere with dbtables database operation.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    if string.find(s, _table_names_key) >= 0 or \
 | 
					    if (s.find(_table_names_key) >= 0 or
 | 
				
			||||||
       string.find(s, _columns) >= 0 or \
 | 
					        s.find(_columns) >= 0 or
 | 
				
			||||||
       string.find(s, _data) >= 0 or \
 | 
					        s.find(_data) >= 0 or
 | 
				
			||||||
       string.find(s, _rowid) >= 0 :
 | 
					        s.find(_rowid) >= 0):
 | 
				
			||||||
 | 
					        # Then
 | 
				
			||||||
        return 1
 | 
					        return 1
 | 
				
			||||||
    else :
 | 
					    else:
 | 
				
			||||||
        return 0
 | 
					        return 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class bsdTableDB :
 | 
					class bsdTableDB :
 | 
				
			||||||
    def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600,
 | 
					    def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600,
 | 
				
			||||||
                 recover=0, dbflags=0) :
 | 
					                 recover=0, dbflags=0):
 | 
				
			||||||
        """bsdTableDB.open(filename, dbhome, create=0, truncate=0, mode=0600)
 | 
					        """bsdTableDB.open(filename, dbhome, create=0, truncate=0, mode=0600)
 | 
				
			||||||
        Open database name in the dbhome BerkeleyDB directory.
 | 
					        Open database name in the dbhome BerkeleyDB directory.
 | 
				
			||||||
        Use keyword arguments when calling this constructor.
 | 
					        Use keyword arguments when calling this constructor.
 | 
				
			||||||
| 
						 | 
					@ -186,7 +202,7 @@ def _db_print(self) :
 | 
				
			||||||
        cur = self.db.cursor()
 | 
					        cur = self.db.cursor()
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            key, data = cur.first()
 | 
					            key, data = cur.first()
 | 
				
			||||||
            while 1 :
 | 
					            while 1:
 | 
				
			||||||
                print `{key: data}`
 | 
					                print `{key: data}`
 | 
				
			||||||
                next = cur.next()
 | 
					                next = cur.next()
 | 
				
			||||||
                if next:
 | 
					                if next:
 | 
				
			||||||
| 
						 | 
					@ -202,7 +218,7 @@ def CreateTable(self, table, columns):
 | 
				
			||||||
        """CreateTable(table, columns) - Create a new table in the database
 | 
					        """CreateTable(table, columns) - Create a new table in the database
 | 
				
			||||||
        raises TableDBError if it already exists or for other DB errors.
 | 
					        raises TableDBError if it already exists or for other DB errors.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        assert type(columns) == type([])
 | 
					        assert isinstance(columns, ListType)
 | 
				
			||||||
        txn = None
 | 
					        txn = None
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            # checking sanity of the table and column names here on
 | 
					            # checking sanity of the table and column names here on
 | 
				
			||||||
| 
						 | 
					@ -233,9 +249,8 @@ def CreateTable(self, table, columns):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            txn.commit()
 | 
					            txn.commit()
 | 
				
			||||||
            txn = None
 | 
					            txn = None
 | 
				
			||||||
 | 
					 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError, dberror:
 | 
				
			||||||
            if txn :
 | 
					            if txn:
 | 
				
			||||||
                txn.abort()
 | 
					                txn.abort()
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -244,8 +259,8 @@ def ListTableColumns(self, table):
 | 
				
			||||||
        """Return a list of columns in the given table.
 | 
					        """Return a list of columns in the given table.
 | 
				
			||||||
        [] if the table doesn't exist.
 | 
					        [] if the table doesn't exist.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        assert type(table) == type('')
 | 
					        assert isinstance(table, StringType)
 | 
				
			||||||
        if contains_metastrings(table) :
 | 
					        if contains_metastrings(table):
 | 
				
			||||||
            raise ValueError, "bad table name: contains reserved metastrings"
 | 
					            raise ValueError, "bad table name: contains reserved metastrings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        columnlist_key = _columns_key(table)
 | 
					        columnlist_key = _columns_key(table)
 | 
				
			||||||
| 
						 | 
					@ -273,7 +288,7 @@ def CreateOrExtendTable(self, table, columns):
 | 
				
			||||||
        additional columns present in the given list as well as
 | 
					        additional columns present in the given list as well as
 | 
				
			||||||
        all of its current columns.
 | 
					        all of its current columns.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        assert type(columns) == type([])
 | 
					        assert isinstance(columns, ListType)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            self.CreateTable(table, columns)
 | 
					            self.CreateTable(table, columns)
 | 
				
			||||||
        except TableAlreadyExists:
 | 
					        except TableAlreadyExists:
 | 
				
			||||||
| 
						 | 
					@ -331,7 +346,7 @@ def __load_column_info(self, table) :
 | 
				
			||||||
    def __new_rowid(self, table, txn) :
 | 
					    def __new_rowid(self, table, txn) :
 | 
				
			||||||
        """Create a new unique row identifier"""
 | 
					        """Create a new unique row identifier"""
 | 
				
			||||||
        unique = 0
 | 
					        unique = 0
 | 
				
			||||||
        while not unique :
 | 
					        while not unique:
 | 
				
			||||||
            # Generate a random 64-bit row ID string
 | 
					            # Generate a random 64-bit row ID string
 | 
				
			||||||
            # (note: this code has <64 bits of randomness
 | 
					            # (note: this code has <64 bits of randomness
 | 
				
			||||||
            # but it's plenty for our database id needs!)
 | 
					            # but it's plenty for our database id needs!)
 | 
				
			||||||
| 
						 | 
					@ -358,14 +373,14 @@ def Insert(self, table, rowdict) :
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        txn = None
 | 
					        txn = None
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            if not self.db.has_key(_columns_key(table)) :
 | 
					            if not self.db.has_key(_columns_key(table)):
 | 
				
			||||||
                raise TableDBError, "unknown table"
 | 
					                raise TableDBError, "unknown table"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # check the validity of each column name
 | 
					            # check the validity of each column name
 | 
				
			||||||
            if not self.__tablecolumns.has_key(table) :
 | 
					            if not self.__tablecolumns.has_key(table):
 | 
				
			||||||
                self.__load_column_info(table)
 | 
					                self.__load_column_info(table)
 | 
				
			||||||
            for column in rowdict.keys() :
 | 
					            for column in rowdict.keys() :
 | 
				
			||||||
                if not self.__tablecolumns[table].count(column) :
 | 
					                if not self.__tablecolumns[table].count(column):
 | 
				
			||||||
                    raise TableDBError, "unknown column: "+`column`
 | 
					                    raise TableDBError, "unknown column: "+`column`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # get a unique row identifier for this row
 | 
					            # get a unique row identifier for this row
 | 
				
			||||||
| 
						 | 
					@ -373,7 +388,7 @@ def Insert(self, table, rowdict) :
 | 
				
			||||||
            rowid = self.__new_rowid(table, txn=txn)
 | 
					            rowid = self.__new_rowid(table, txn=txn)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # insert the row values into the table database
 | 
					            # insert the row values into the table database
 | 
				
			||||||
            for column, dataitem in rowdict.items() :
 | 
					            for column, dataitem in rowdict.items():
 | 
				
			||||||
                # store the value
 | 
					                # store the value
 | 
				
			||||||
                self.db.put(_data_key(table, column, rowid), dataitem, txn=txn)
 | 
					                self.db.put(_data_key(table, column, rowid), dataitem, txn=txn)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -392,7 +407,7 @@ def Insert(self, table, rowdict) :
 | 
				
			||||||
            raise TableDBError, dberror[1], info[2]
 | 
					            raise TableDBError, dberror[1], info[2]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def Modify(self, table, conditions={}, mappings={}) :
 | 
					    def Modify(self, table, conditions={}, mappings={}):
 | 
				
			||||||
        """Modify(table, conditions) - Modify in rows matching 'conditions'
 | 
					        """Modify(table, conditions) - Modify in rows matching 'conditions'
 | 
				
			||||||
        using mapping functions in 'mappings'
 | 
					        using mapping functions in 'mappings'
 | 
				
			||||||
        * conditions is a dictionary keyed on column names
 | 
					        * conditions is a dictionary keyed on column names
 | 
				
			||||||
| 
						 | 
					@ -407,10 +422,10 @@ def Modify(self, table, conditions={}, mappings={}) :
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # modify only requested columns
 | 
					            # modify only requested columns
 | 
				
			||||||
            columns = mappings.keys()
 | 
					            columns = mappings.keys()
 | 
				
			||||||
            for rowid in matching_rowids.keys() :
 | 
					            for rowid in matching_rowids.keys():
 | 
				
			||||||
                txn = None
 | 
					                txn = None
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    for column in columns :
 | 
					                    for column in columns:
 | 
				
			||||||
                        txn = self.env.txn_begin()
 | 
					                        txn = self.env.txn_begin()
 | 
				
			||||||
                        # modify the requested column
 | 
					                        # modify the requested column
 | 
				
			||||||
                        try:
 | 
					                        try:
 | 
				
			||||||
| 
						 | 
					@ -433,14 +448,14 @@ def Modify(self, table, conditions={}, mappings={}) :
 | 
				
			||||||
                        txn = None
 | 
					                        txn = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                except DBError, dberror:
 | 
					                except DBError, dberror:
 | 
				
			||||||
                    if txn :
 | 
					                    if txn:
 | 
				
			||||||
                        txn.abort()
 | 
					                        txn.abort()
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError, dberror:
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def Delete(self, table, conditions={}) :
 | 
					    def Delete(self, table, conditions={}):
 | 
				
			||||||
        """Delete(table, conditions) - Delete items matching the given
 | 
					        """Delete(table, conditions) - Delete items matching the given
 | 
				
			||||||
        conditions from the table.
 | 
					        conditions from the table.
 | 
				
			||||||
        * conditions is a dictionary keyed on column names
 | 
					        * conditions is a dictionary keyed on column names
 | 
				
			||||||
| 
						 | 
					@ -452,11 +467,11 @@ def Delete(self, table, conditions={}) :
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # delete row data from all columns
 | 
					            # delete row data from all columns
 | 
				
			||||||
            columns = self.__tablecolumns[table]
 | 
					            columns = self.__tablecolumns[table]
 | 
				
			||||||
            for rowid in matching_rowids.keys() :
 | 
					            for rowid in matching_rowids.keys():
 | 
				
			||||||
                txn = None
 | 
					                txn = None
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    txn = self.env.txn_begin()
 | 
					                    txn = self.env.txn_begin()
 | 
				
			||||||
                    for column in columns :
 | 
					                    for column in columns:
 | 
				
			||||||
                        # delete the data key
 | 
					                        # delete the data key
 | 
				
			||||||
                        try:
 | 
					                        try:
 | 
				
			||||||
                            self.db.delete(_data_key(table, column, rowid),
 | 
					                            self.db.delete(_data_key(table, column, rowid),
 | 
				
			||||||
| 
						 | 
					@ -473,15 +488,14 @@ def Delete(self, table, conditions={}) :
 | 
				
			||||||
                    txn.commit()
 | 
					                    txn.commit()
 | 
				
			||||||
                    txn = None
 | 
					                    txn = None
 | 
				
			||||||
                except DBError, dberror:
 | 
					                except DBError, dberror:
 | 
				
			||||||
                    if txn :
 | 
					                    if txn:
 | 
				
			||||||
                        txn.abort()
 | 
					                        txn.abort()
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
 | 
					 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError, dberror:
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def Select(self, table, columns, conditions={}) :
 | 
					    def Select(self, table, columns, conditions={}):
 | 
				
			||||||
        """Select(table, conditions) - retrieve specific row data
 | 
					        """Select(table, conditions) - retrieve specific row data
 | 
				
			||||||
        Returns a list of row column->value mapping dictionaries.
 | 
					        Returns a list of row column->value mapping dictionaries.
 | 
				
			||||||
        * columns is a list of which column data to return.  If
 | 
					        * columns is a list of which column data to return.  If
 | 
				
			||||||
| 
						 | 
					@ -491,19 +505,18 @@ def Select(self, table, columns, conditions={}) :
 | 
				
			||||||
          argument and returning a boolean.
 | 
					          argument and returning a boolean.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            if not self.__tablecolumns.has_key(table) :
 | 
					            if not self.__tablecolumns.has_key(table):
 | 
				
			||||||
                self.__load_column_info(table)
 | 
					                self.__load_column_info(table)
 | 
				
			||||||
            if columns is None :
 | 
					            if columns is None:
 | 
				
			||||||
                columns = self.__tablecolumns[table]
 | 
					                columns = self.__tablecolumns[table]
 | 
				
			||||||
            matching_rowids = self.__Select(table, columns, conditions)
 | 
					            matching_rowids = self.__Select(table, columns, conditions)
 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError, dberror:
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # return the matches as a list of dictionaries
 | 
					        # return the matches as a list of dictionaries
 | 
				
			||||||
        return matching_rowids.values()
 | 
					        return matching_rowids.values()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __Select(self, table, columns, conditions) :
 | 
					    def __Select(self, table, columns, conditions):
 | 
				
			||||||
        """__Select() - Used to implement Select and Delete (above)
 | 
					        """__Select() - Used to implement Select and Delete (above)
 | 
				
			||||||
        Returns a dictionary keyed on rowids containing dicts
 | 
					        Returns a dictionary keyed on rowids containing dicts
 | 
				
			||||||
        holding the row data for columns listed in the columns param
 | 
					        holding the row data for columns listed in the columns param
 | 
				
			||||||
| 
						 | 
					@ -513,26 +526,26 @@ def __Select(self, table, columns, conditions) :
 | 
				
			||||||
        argument and returning a boolean.
 | 
					        argument and returning a boolean.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        # check the validity of each column name
 | 
					        # check the validity of each column name
 | 
				
			||||||
        if not self.__tablecolumns.has_key(table) :
 | 
					        if not self.__tablecolumns.has_key(table):
 | 
				
			||||||
            self.__load_column_info(table)
 | 
					            self.__load_column_info(table)
 | 
				
			||||||
        if columns is None :
 | 
					        if columns is None:
 | 
				
			||||||
            columns = self.tablecolumns[table]
 | 
					            columns = self.tablecolumns[table]
 | 
				
			||||||
        for column in (columns + conditions.keys()) :
 | 
					        for column in (columns + conditions.keys()):
 | 
				
			||||||
            if not self.__tablecolumns[table].count(column) :
 | 
					            if not self.__tablecolumns[table].count(column):
 | 
				
			||||||
                raise TableDBError, "unknown column: "+`column`
 | 
					                raise TableDBError, "unknown column: "+`column`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # keyed on rows that match so far, containings dicts keyed on
 | 
					        # keyed on rows that match so far, containings dicts keyed on
 | 
				
			||||||
        # column names containing the data for that row and column.
 | 
					        # column names containing the data for that row and column.
 | 
				
			||||||
        matching_rowids = {}
 | 
					        matching_rowids = {}
 | 
				
			||||||
 | 
					        # keys are rowids that do not match
 | 
				
			||||||
        rejected_rowids = {} # keys are rowids that do not match
 | 
					        rejected_rowids = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # attempt to sort the conditions in such a way as to minimize full
 | 
					        # attempt to sort the conditions in such a way as to minimize full
 | 
				
			||||||
        # column lookups
 | 
					        # column lookups
 | 
				
			||||||
        def cmp_conditions(atuple, btuple):
 | 
					        def cmp_conditions(atuple, btuple):
 | 
				
			||||||
            a = atuple[1]
 | 
					            a = atuple[1]
 | 
				
			||||||
            b = btuple[1]
 | 
					            b = btuple[1]
 | 
				
			||||||
            if type(a) == type(b) :
 | 
					            if type(a) is type(b):
 | 
				
			||||||
                if isinstance(a, PrefixCond) and isinstance(b, PrefixCond):
 | 
					                if isinstance(a, PrefixCond) and isinstance(b, PrefixCond):
 | 
				
			||||||
                    # longest prefix first
 | 
					                    # longest prefix first
 | 
				
			||||||
                    return cmp(len(b.prefix), len(a.prefix))
 | 
					                    return cmp(len(b.prefix), len(a.prefix))
 | 
				
			||||||
| 
						 | 
					@ -557,38 +570,38 @@ def cmp_conditions(atuple, btuple):
 | 
				
			||||||
        # Apply conditions to column data to find what we want
 | 
					        # Apply conditions to column data to find what we want
 | 
				
			||||||
        cur = self.db.cursor()
 | 
					        cur = self.db.cursor()
 | 
				
			||||||
        column_num = -1
 | 
					        column_num = -1
 | 
				
			||||||
        for column, condition in conditionlist :
 | 
					        for column, condition in conditionlist:
 | 
				
			||||||
            column_num = column_num + 1
 | 
					            column_num = column_num + 1
 | 
				
			||||||
            searchkey = _search_col_data_key(table, column)
 | 
					            searchkey = _search_col_data_key(table, column)
 | 
				
			||||||
            # speedup: don't linear search columns within loop
 | 
					            # speedup: don't linear search columns within loop
 | 
				
			||||||
            if column in columns :
 | 
					            if column in columns:
 | 
				
			||||||
                savethiscolumndata = 1  # save the data for return
 | 
					                savethiscolumndata = 1  # save the data for return
 | 
				
			||||||
            else :
 | 
					            else:
 | 
				
			||||||
                savethiscolumndata = 0  # data only used for selection
 | 
					                savethiscolumndata = 0  # data only used for selection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                key, data = cur.set_range(searchkey)
 | 
					                key, data = cur.set_range(searchkey)
 | 
				
			||||||
                while key[:len(searchkey)] == searchkey :
 | 
					                while key[:len(searchkey)] == searchkey:
 | 
				
			||||||
                    # extract the rowid from the key
 | 
					                    # extract the rowid from the key
 | 
				
			||||||
                    rowid = key[-_rowid_str_len:]
 | 
					                    rowid = key[-_rowid_str_len:]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if not rejected_rowids.has_key(rowid) :
 | 
					                    if not rejected_rowids.has_key(rowid):
 | 
				
			||||||
                        # if no condition was specified or the condition
 | 
					                        # if no condition was specified or the condition
 | 
				
			||||||
                        # succeeds, add row to our match list.
 | 
					                        # succeeds, add row to our match list.
 | 
				
			||||||
                        if not condition or condition(data) :
 | 
					                        if not condition or condition(data):
 | 
				
			||||||
                            if not matching_rowids.has_key(rowid) :
 | 
					                            if not matching_rowids.has_key(rowid):
 | 
				
			||||||
                                matching_rowids[rowid] = {}
 | 
					                                matching_rowids[rowid] = {}
 | 
				
			||||||
                            if savethiscolumndata :
 | 
					                            if savethiscolumndata:
 | 
				
			||||||
                                matching_rowids[rowid][column] = data
 | 
					                                matching_rowids[rowid][column] = data
 | 
				
			||||||
                        else :
 | 
					                        else:
 | 
				
			||||||
                            if matching_rowids.has_key(rowid) :
 | 
					                            if matching_rowids.has_key(rowid):
 | 
				
			||||||
                                del matching_rowids[rowid]
 | 
					                                del matching_rowids[rowid]
 | 
				
			||||||
                            rejected_rowids[rowid] = rowid
 | 
					                            rejected_rowids[rowid] = rowid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    key, data = cur.next()
 | 
					                    key, data = cur.next()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            except DBError, dberror:
 | 
					            except DBError, dberror:
 | 
				
			||||||
                if dberror[0] != DB_NOTFOUND :
 | 
					                if dberror[0] != DB_NOTFOUND:
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -599,16 +612,16 @@ def cmp_conditions(atuple, btuple):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # extract any remaining desired column data from the
 | 
					        # extract any remaining desired column data from the
 | 
				
			||||||
        # database for the matching rows.
 | 
					        # database for the matching rows.
 | 
				
			||||||
        if len(columns) > 0 :
 | 
					        if len(columns) > 0:
 | 
				
			||||||
            for rowid, rowdata in matching_rowids.items() :
 | 
					            for rowid, rowdata in matching_rowids.items():
 | 
				
			||||||
                for column in columns :
 | 
					                for column in columns:
 | 
				
			||||||
                    if rowdata.has_key(column) :
 | 
					                    if rowdata.has_key(column):
 | 
				
			||||||
                        continue
 | 
					                        continue
 | 
				
			||||||
                    try:
 | 
					                    try:
 | 
				
			||||||
                        rowdata[column] = self.db.get(
 | 
					                        rowdata[column] = self.db.get(
 | 
				
			||||||
                            _data_key(table, column, rowid))
 | 
					                            _data_key(table, column, rowid))
 | 
				
			||||||
                    except DBError, dberror:
 | 
					                    except DBError, dberror:
 | 
				
			||||||
                        if dberror[0] != DB_NOTFOUND :
 | 
					                        if dberror[0] != DB_NOTFOUND:
 | 
				
			||||||
                            raise
 | 
					                            raise
 | 
				
			||||||
                        rowdata[column] = None
 | 
					                        rowdata[column] = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -616,9 +629,8 @@ def cmp_conditions(atuple, btuple):
 | 
				
			||||||
        return matching_rowids
 | 
					        return matching_rowids
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def Drop(self, table) :
 | 
					    def Drop(self, table):
 | 
				
			||||||
        """Remove an entire table from the database
 | 
					        """Remove an entire table from the database"""
 | 
				
			||||||
        """
 | 
					 | 
				
			||||||
        txn = None
 | 
					        txn = None
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            txn = self.env.txn_begin()
 | 
					            txn = self.env.txn_begin()
 | 
				
			||||||
| 
						 | 
					@ -630,25 +642,25 @@ def Drop(self, table) :
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # delete all keys containing this tables column and row info
 | 
					            # delete all keys containing this tables column and row info
 | 
				
			||||||
            table_key = _search_all_data_key(table)
 | 
					            table_key = _search_all_data_key(table)
 | 
				
			||||||
            while 1 :
 | 
					            while 1:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    key, data = cur.set_range(table_key)
 | 
					                    key, data = cur.set_range(table_key)
 | 
				
			||||||
                except DBNotFoundError:
 | 
					                except DBNotFoundError:
 | 
				
			||||||
                    break
 | 
					                    break
 | 
				
			||||||
                # only delete items in this table
 | 
					                # only delete items in this table
 | 
				
			||||||
                if key[:len(table_key)] != table_key :
 | 
					                if key[:len(table_key)] != table_key:
 | 
				
			||||||
                    break
 | 
					                    break
 | 
				
			||||||
                cur.delete()
 | 
					                cur.delete()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # delete all rowids used by this table
 | 
					            # delete all rowids used by this table
 | 
				
			||||||
            table_key = _search_rowid_key(table)
 | 
					            table_key = _search_rowid_key(table)
 | 
				
			||||||
            while 1 :
 | 
					            while 1:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    key, data = cur.set_range(table_key)
 | 
					                    key, data = cur.set_range(table_key)
 | 
				
			||||||
                except DBNotFoundError:
 | 
					                except DBNotFoundError:
 | 
				
			||||||
                    break
 | 
					                    break
 | 
				
			||||||
                # only delete items in this table
 | 
					                # only delete items in this table
 | 
				
			||||||
                if key[:len(table_key)] != table_key :
 | 
					                if key[:len(table_key)] != table_key:
 | 
				
			||||||
                    break
 | 
					                    break
 | 
				
			||||||
                cur.delete()
 | 
					                cur.delete()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -669,10 +681,10 @@ def Drop(self, table) :
 | 
				
			||||||
            txn.commit()
 | 
					            txn.commit()
 | 
				
			||||||
            txn = None
 | 
					            txn = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if self.__tablecolumns.has_key(table) :
 | 
					            if self.__tablecolumns.has_key(table):
 | 
				
			||||||
                del self.__tablecolumns[table]
 | 
					                del self.__tablecolumns[table]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        except DBError, dberror:
 | 
					        except DBError, dberror:
 | 
				
			||||||
            if txn :
 | 
					            if txn:
 | 
				
			||||||
                txn.abort()
 | 
					                txn.abort()
 | 
				
			||||||
            raise TableDBError, dberror[1]
 | 
					            raise TableDBError, dberror[1]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,12 @@
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
from time import sleep as _sleep
 | 
					from time import sleep as _sleep
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import _db
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# always sleep at least N seconds between retrys
 | 
					# always sleep at least N seconds between retrys
 | 
				
			||||||
_deadlock_MinSleepTime = 1.0/64
 | 
					_deadlock_MinSleepTime = 1.0/64
 | 
				
			||||||
| 
						 | 
					@ -60,7 +65,7 @@ def DeadlockWrap(function, *_args, **_kwargs):
 | 
				
			||||||
    while 1:
 | 
					    while 1:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            return function(*_args, **_kwargs)
 | 
					            return function(*_args, **_kwargs)
 | 
				
			||||||
        except _db.DBLockDeadlockError:
 | 
					        except db.DBLockDeadlockError:
 | 
				
			||||||
            if _deadlock_VerboseFile:
 | 
					            if _deadlock_VerboseFile:
 | 
				
			||||||
                _deadlock_VerboseFile.write(
 | 
					                _deadlock_VerboseFile.write(
 | 
				
			||||||
                    'dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime)
 | 
					                    'dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,12 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def print_versions():
 | 
					def print_versions():
 | 
				
			||||||
    from bsddb import db
 | 
					    try:
 | 
				
			||||||
 | 
					        # For Python 2.3
 | 
				
			||||||
 | 
					        from bsddb import db
 | 
				
			||||||
 | 
					    except ImportError:
 | 
				
			||||||
 | 
					        # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					        from bsddb3 import db
 | 
				
			||||||
    print
 | 
					    print
 | 
				
			||||||
    print '-=' * 38
 | 
					    print '-=' * 38
 | 
				
			||||||
    print db.DB_VERSION_STRING
 | 
					    print db.DB_VERSION_STRING
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,12 @@
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db, dbshelve
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db, dbshelve
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db, dbshelve
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,12 @@
 | 
				
			||||||
from pprint import pprint
 | 
					from pprint import pprint
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,13 +4,18 @@
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import sys, os, string
 | 
					import sys, os, string
 | 
				
			||||||
from bsddb import hashopen, btopen, rnopen
 | 
					 | 
				
			||||||
import bsddb
 | 
					import bsddb
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
import tempfile
 | 
					import tempfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db, hashopen, btopen, rnopen
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db, hashopen, btopen, rnopen
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CompatibilityTestCase(unittest.TestCase):
 | 
					class CompatibilityTestCase(unittest.TestCase):
 | 
				
			||||||
| 
						 | 
					@ -126,7 +131,7 @@ def do_bthash_test(self, factory, what):
 | 
				
			||||||
                if verbose: print "truth test: true"
 | 
					                if verbose: print "truth test: true"
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                if verbose: print "truth test: false"
 | 
					                if verbose: print "truth test: false"
 | 
				
			||||||
        except bsddb.error:
 | 
					        except db.DBError:
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.fail("Exception expected")
 | 
					            self.fail("Exception expected")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,12 @@
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
import glob
 | 
					import glob
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db, dbobj
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db, dbobj
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db, dbobj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,12 @@
 | 
				
			||||||
from types import *
 | 
					from types import *
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import dbshelve, db
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db, dbshelve
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db, dbshelve
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,12 @@
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db, dbtables
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db, dbtables
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db, dbtables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,12 @@
 | 
				
			||||||
import glob
 | 
					import glob
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,12 @@
 | 
				
			||||||
from pprint import pprint
 | 
					from pprint import pprint
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,12 @@
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,8 +5,12 @@
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db
 | 
					try:
 | 
				
			||||||
from bsddb import dbshelve
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db, dbshelve
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db, dbshelve
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from test.test_support import verbose
 | 
					from test.test_support import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,12 @@
 | 
				
			||||||
from pprint import pprint
 | 
					from pprint import pprint
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,9 +8,15 @@
 | 
				
			||||||
from pprint import pprint
 | 
					from pprint import pprint
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bsddb import db
 | 
					 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
 | 
					letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,14 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import unittest
 | 
					import unittest
 | 
				
			||||||
from test_all import verbose
 | 
					from test_all import verbose
 | 
				
			||||||
from bsddb import db, dbutils
 | 
					
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
 | 
					    # For Python 2.3
 | 
				
			||||||
 | 
					    from bsddb import db, dbutils
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    # For earlier Pythons w/distutils pybsddb
 | 
				
			||||||
 | 
					    from bsddb3 import db, dbutils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#----------------------------------------------------------------------
 | 
					#----------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue