summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/dbshelve.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/bsddb/dbshelve.py b/Lib/bsddb/dbshelve.py
index 003038b..d341ab7 100644
--- a/Lib/bsddb/dbshelve.py
+++ b/Lib/bsddb/dbshelve.py
@@ -67,7 +67,7 @@ def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH,
elif sflag == 'n':
flags = db.DB_TRUNCATE | db.DB_CREATE
else:
- raise error, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags"
+ raise db.DBError, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags"
d = DBShelf(dbenv)
d.open(filename, dbname, filetype, flags, mode)
@@ -145,10 +145,16 @@ class DBShelf(DictMixin):
#-----------------------------------
# Other methods
- def append(self, value, txn=None):
+ def __append(self, value, txn=None):
data = cPickle.dumps(value, self.binary)
return self.db.append(data, txn)
+ def append(self, value, txn=None):
+ if self.get_type() != db.DB_RECNO:
+ self.append = self.__append
+ return self.append(value, txn=txn)
+ raise db.DBError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO"
+
def associate(self, secondaryDB, callback, flags=0):
def _shelf_callback(priKey, priData, realCallback=callback):