diff roundup/backends/back_anydbm.py @ 4383:0d9369d35483

fix up some pre-Python2.6 compatibility issues in the *dbm interface
author Richard Jones <richard@users.sourceforge.net>
date Sat, 10 Jul 2010 03:45:17 +0000
parents 667c818f6a22
children 9655a1b65974
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py	Thu Jul 01 02:20:51 2010 +0000
+++ b/roundup/backends/back_anydbm.py	Sat Jul 10 03:45:17 2010 +0000
@@ -24,7 +24,7 @@
 
 import os, marshal, re, weakref, string, copy, time, shutil, logging
 
-from roundup.anypy.dbm_ import anydbm, whichdb
+from roundup.anypy.dbm_ import anydbm, whichdb, key_in
 
 from roundup import hyperdb, date, password, roundupdb, security, support
 from roundup.support import reversed
@@ -248,7 +248,7 @@
         """
         # open the ids DB - create if if doesn't exist
         db = self.opendb('_ids', 'c')
-        if classname in db:
+        if key_in(db, classname):
             newid = db[classname] = str(int(db[classname]) + 1)
         else:
             # the count() bit is transitional - older dbs won't start at 1
@@ -322,7 +322,7 @@
         # get from the database and save in the cache
         if db is None:
             db = self.getclassdb(classname)
-        if nodeid not in db:
+        if not key_in(db, nodeid):
             raise IndexError("no such %s %s"%(classname, nodeid))
 
         # check the uncommitted, destroyed nodes
@@ -435,7 +435,7 @@
         # not in the cache - check the database
         if db is None:
             db = self.getclassdb(classname)
-        return nodeid in db
+        return key_in(db, nodeid)
 
     def countnodes(self, classname, db=None):
         count = 0
@@ -552,7 +552,7 @@
             db_type = self.determine_db_type(path)
             db = self.opendb(db_name, 'w')
 
-            for key in db:
+            for key in db.keys():
                 # get the journal for this db entry
                 journal = marshal.loads(db[key])
                 l = []
@@ -679,7 +679,7 @@
         db = self.getCachedJournalDB(classname)
 
         # now insert the journal entry
-        if nodeid in db:
+        if key_in(db, nodeid):
             # append to existing
             s = db[nodeid]
             l = marshal.loads(s)
@@ -704,12 +704,12 @@
     def doDestroyNode(self, classname, nodeid):
         # delete from the class database
         db = self.getCachedClassDB(classname)
-        if nodeid in db:
+        if key_in(db, nodeid):
             del db[nodeid]
 
         # delete from the database
         db = self.getCachedJournalDB(classname)
-        if nodeid in db:
+        if key_in(db, nodeid):
             del db[nodeid]
 
     def rollback(self):
@@ -1530,12 +1530,12 @@
             db = self.db.getclassdb(self.classname)
             must_close = True
         try:
-            res.extend(db)
+            res.extend(db.keys())
 
             # remove the uncommitted, destroyed nodes
             if self.classname in self.db.destroyednodes:
                 for nodeid in self.db.destroyednodes[self.classname]:
-                    if nodeid in db:
+                    if key_in(db, nodeid):
                         res.remove(nodeid)
 
             # check retired flag

Roundup Issue Tracker: http://roundup-tracker.org/