Mercurial > p > roundup > code
diff roundup/backends/back_anydbm.py @ 5011:d5da643b3d25
Remove key_in() from roundup.anypy.dbm_
The key_in() function was just a shim to use the best available option
out of 'd.has_key(key)' and 'key in d'. The 'd.has_key(key)' flavour has
been deprecated in favour of 'key in d' which based on testing has been
available since at least python v2.5 which is the oldest being
supported.
| author | John Kristensen <john@jerrykan.com> |
|---|---|
| date | Fri, 13 Feb 2015 00:20:43 +1100 |
| parents | 0a05c4d9a221 |
| children | 5251e97b1de0 |
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py Wed Jan 06 16:02:34 2016 +1100 +++ b/roundup/backends/back_anydbm.py Fri Feb 13 00:20:43 2015 +1100 @@ -24,7 +24,7 @@ import os, marshal, re, weakref, string, copy, time, shutil, logging -from roundup.anypy.dbm_ import anydbm, whichdb, key_in +from roundup.anypy.dbm_ import anydbm, whichdb from roundup import hyperdb, date, password, roundupdb, security, support from roundup.backends import locking @@ -332,7 +332,7 @@ """ # open the ids DB - create if if doesn't exist db = self.opendb('_ids', 'c') - if key_in(db, classname): + if classname in db: newid = db[classname] = str(int(db[classname]) + 1) else: # the count() bit is transitional - older dbs won't start at 1 @@ -409,7 +409,7 @@ # get from the database and save in the cache if db is None: db = self.getclassdb(classname) - if not key_in(db, nodeid): + if nodeid not in db: raise IndexError("no such %s %s"%(classname, nodeid)) # check the uncommitted, destroyed nodes @@ -521,7 +521,7 @@ # not in the cache - check the database if db is None: db = self.getclassdb(classname) - return key_in(db, nodeid) + return nodeid in db def countnodes(self, classname, db=None): count = 0 @@ -783,7 +783,7 @@ db = self.getCachedJournalDB(classname) # now insert the journal entry - if key_in(db, nodeid): + if nodeid in db: # append to existing s = db[nodeid] l = marshal.loads(s) @@ -808,12 +808,12 @@ def doDestroyNode(self, classname, nodeid): # delete from the class database db = self.getCachedClassDB(classname) - if key_in(db, nodeid): + if nodeid in db: del db[nodeid] # delete from the database db = self.getCachedJournalDB(classname) - if key_in(db, nodeid): + if nodeid in db: del db[nodeid] def rollback(self): @@ -1624,7 +1624,7 @@ # remove the uncommitted, destroyed nodes if self.classname in self.db.destroyednodes: for nodeid in self.db.destroyednodes[self.classname]: - if key_in(db, nodeid): + if nodeid in db: res.remove(nodeid) # check retired flag
