Code

anydbm should return brand new items, even if cache is turned off
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 13 Feb 2003 07:33:38 +0000 (07:33 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 13 Feb 2003 07:33:38 +0000 (07:33 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1502 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/backends/back_anydbm.py

index ace6c45e408f97bde97771242eb9d9bd10fbb9d6..8d389c30d511aa1b059dd228db02a178d9219d0a 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: back_anydbm.py,v 1.101 2003-02-12 00:00:18 richard Exp $
+#$Id: back_anydbm.py,v 1.102 2003-02-13 07:33:38 richard Exp $
 '''
 This module defines a backend that saves the hyperdatabase in a database
 chosen by anydbm. It is guaranteed to always be available in python
@@ -299,6 +299,13 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database):
         if db is None:
             db = self.getclassdb(classname)
         if not db.has_key(nodeid):
+            # try the cache - might be a brand-new node
+            cache_dict = self.cache.setdefault(classname, {})
+            if cache_dict.has_key(nodeid):
+                if __debug__:
+                    print >>hyperdb.TRACE, 'get %s %s cached'%(classname,
+                        nodeid)
+                return cache_dict[nodeid]
             raise IndexError, "no such %s %s"%(classname, nodeid)
 
         # check the uncommitted, destroyed nodes