[Python-checkins] python/dist/src/Lib/bsddb dbshelve.py,1.9,1.10

greg at users.sourceforge.net greg at users.sourceforge.net
Tue Mar 16 13:50:29 EST 2004


Update of /cvsroot/python/python/dist/src/Lib/bsddb
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9526
Modified Files:
	dbshelve.py 
Log Message:
* 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
Index: dbshelve.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/dbshelve.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** dbshelve.py	21 Sep 2003 00:08:14 -0000	1.9
--- dbshelve.py	16 Mar 2004 18:50:26 -0000	1.10
***************
*** 68,72 ****
 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"
 
 d = DBShelf(dbenv)
--- 68,72 ----
 flags = db.DB_TRUNCATE | db.DB_CREATE
 else:
! raise db.DBError, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags"
 
 d = DBShelf(dbenv)
***************
*** 146,153 ****
 # Other methods
 
! def append(self, value, txn=None):
 data = cPickle.dumps(value, self.binary)
 return self.db.append(data, txn)
 
 
 def associate(self, secondaryDB, callback, flags=0):
--- 146,159 ----
 # Other methods
 
! 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):


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /