2424
2525import os , marshal , re , weakref , string , copy , time , shutil , logging
2626
27- from roundup .anypy .dbm_ import anydbm , whichdb
27+ from roundup .anypy .dbm_ import anydbm , whichdb , key_in
2828
2929from roundup import hyperdb , date , password , roundupdb , security , support
3030from roundup .support import reversed
@@ -248,7 +248,7 @@ def newid(self, classname):
248248 """
249249 # open the ids DB - create if if doesn't exist
250250 db = self .opendb ('_ids' , 'c' )
251- if classname in db :
251+ if key_in ( db , classname ) :
252252 newid = db [classname ] = str (int (db [classname ]) + 1 )
253253 else :
254254 # the count() bit is transitional - older dbs won't start at 1
@@ -322,7 +322,7 @@ def getnode(self, classname, nodeid, db=None, cache=1):
322322 # get from the database and save in the cache
323323 if db is None :
324324 db = self .getclassdb (classname )
325- if nodeid not in db :
325+ if not key_in ( db , nodeid ) :
326326 raise IndexError ("no such %s %s" % (classname , nodeid ))
327327
328328 # check the uncommitted, destroyed nodes
@@ -435,7 +435,7 @@ def hasnode(self, classname, nodeid, db=None):
435435 # not in the cache - check the database
436436 if db is None :
437437 db = self .getclassdb (classname )
438- return nodeid in db
438+ return key_in ( db , nodeid )
439439
440440 def countnodes (self , classname , db = None ):
441441 count = 0
@@ -552,7 +552,7 @@ def pack(self, pack_before):
552552 db_type = self .determine_db_type (path )
553553 db = self .opendb (db_name , 'w' )
554554
555- for key in db :
555+ for key in db . keys () :
556556 # get the journal for this db entry
557557 journal = marshal .loads (db [key ])
558558 l = []
@@ -679,7 +679,7 @@ def doSaveJournal(self, classname, nodeid, action, params, creator,
679679 db = self .getCachedJournalDB (classname )
680680
681681 # now insert the journal entry
682- if nodeid in db :
682+ if key_in ( db , nodeid ) :
683683 # append to existing
684684 s = db [nodeid ]
685685 l = marshal .loads (s )
@@ -704,12 +704,12 @@ def doSetJournal(self, classname, nodeid, journal):
704704 def doDestroyNode (self , classname , nodeid ):
705705 # delete from the class database
706706 db = self .getCachedClassDB (classname )
707- if nodeid in db :
707+ if key_in ( db , nodeid ) :
708708 del db [nodeid ]
709709
710710 # delete from the database
711711 db = self .getCachedJournalDB (classname )
712- if nodeid in db :
712+ if key_in ( db , nodeid ) :
713713 del db [nodeid ]
714714
715715 def rollback (self ):
@@ -1530,12 +1530,12 @@ def getnodeids(self, db=None, retired=None):
15301530 db = self .db .getclassdb (self .classname )
15311531 must_close = True
15321532 try :
1533- res .extend (db )
1533+ res .extend (db . keys () )
15341534
15351535 # remove the uncommitted, destroyed nodes
15361536 if self .classname in self .db .destroyednodes :
15371537 for nodeid in self .db .destroyednodes [self .classname ]:
1538- if nodeid in db :
1538+ if key_in ( db , nodeid ) :
15391539 res .remove (nodeid )
15401540
15411541 # check retired flag
0 commit comments