Mercurial > p > roundup > code
comparison roundup/backends/back_anydbm.py @ 1951:767ff2a03eee
more unit tests to improve coverage (up from 85% to 88% for anydbm! :)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 05 Dec 2003 09:47:46 +0000 |
| parents | 3bdd34547fa7 |
| children | b00ad075bb2f |
comparison
equal
deleted
inserted
replaced
| 1950:1eba6b6ca159 | 1951:767ff2a03eee |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 #$Id: back_anydbm.py,v 1.132 2003-11-16 18:41:40 jlgijsbers Exp $ | 18 #$Id: back_anydbm.py,v 1.133 2003-12-05 09:47:46 richard Exp $ |
| 19 ''' | 19 ''' |
| 20 This module defines a backend that saves the hyperdatabase in a database | 20 This module defines a backend that saves the hyperdatabase in a database |
| 21 chosen by anydbm. It is guaranteed to always be available in python | 21 chosen by anydbm. It is guaranteed to always be available in python |
| 22 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several | 22 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several |
| 23 serious bugs, and is not available) | 23 serious bugs, and is not available) |
| 308 | 308 |
| 309 # get from the database and save in the cache | 309 # get from the database and save in the cache |
| 310 if db is None: | 310 if db is None: |
| 311 db = self.getclassdb(classname) | 311 db = self.getclassdb(classname) |
| 312 if not db.has_key(nodeid): | 312 if not db.has_key(nodeid): |
| 313 # try the cache - might be a brand-new node | |
| 314 cache_dict = self.cache.setdefault(classname, {}) | |
| 315 if cache_dict.has_key(nodeid): | |
| 316 if __debug__: | |
| 317 print >>hyperdb.TRACE, 'get %s %s cached'%(classname, | |
| 318 nodeid) | |
| 319 return cache_dict[nodeid] | |
| 320 raise IndexError, "no such %s %s"%(classname, nodeid) | 313 raise IndexError, "no such %s %s"%(classname, nodeid) |
| 321 | 314 |
| 322 # check the uncommitted, destroyed nodes | 315 # check the uncommitted, destroyed nodes |
| 323 if (self.destroyednodes.has_key(classname) and | 316 if (self.destroyednodes.has_key(classname) and |
| 324 self.destroyednodes[classname].has_key(nodeid)): | 317 self.destroyednodes[classname].has_key(nodeid)): |
| 1538 | 1531 |
| 1539 The return is a list of the id of all nodes that match. | 1532 The return is a list of the id of all nodes that match. |
| 1540 ''' | 1533 ''' |
| 1541 for propname in requirements.keys(): | 1534 for propname in requirements.keys(): |
| 1542 prop = self.properties[propname] | 1535 prop = self.properties[propname] |
| 1543 if isinstance(not prop, String): | 1536 if not isinstance(prop, String): |
| 1544 raise TypeError, "'%s' not a String property"%propname | 1537 raise TypeError, "'%s' not a String property"%propname |
| 1545 requirements[propname] = requirements[propname].lower() | 1538 requirements[propname] = requirements[propname].lower() |
| 1546 l = [] | 1539 l = [] |
| 1547 cldb = self.db.getclassdb(self.classname) | 1540 cldb = self.db.getclassdb(self.classname) |
| 1548 try: | 1541 try: |
