summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/dbshelve.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2004-03-16 18:50:26 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2004-03-16 18:50:26 (GMT)
commit1281f76606cc4195f57d3446b42b97063c3adc1d (patch)
tree9e18ccef8f642e7655fd8b0be942c976689017cb /Lib/bsddb/dbshelve.py
parentbce64ec086026464c14bdedc00599a837d5ad6ef (diff)
downloadcpython-1281f76606cc4195f57d3446b42b97063c3adc1d.zip
cpython-1281f76606cc4195f57d3446b42b97063c3adc1d.tar.gz
cpython-1281f76606cc4195f57d3446b42b97063c3adc1d.tar.bz2
* supply a more useful error message when append() is called on the
wrong type of database in dbshelve. * fix a typo in the exception name when checking args
Diffstat (limited to 'Lib/bsddb/dbshelve.py')
-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):