|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -#$Id: back_anydbm.py,v 1.172 2004-09-29 07:09:13 a1s Exp $ |
| 18 | +#$Id: back_anydbm.py,v 1.173 2004-10-08 05:37:44 richard Exp $ |
19 | 19 | '''This module defines a backend that saves the hyperdatabase in a |
20 | 20 | database chosen by anydbm. It is guaranteed to always be available in python |
21 | 21 | versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several |
|
46 | 46 | def db_exists(config): |
47 | 47 | # check for the user db |
48 | 48 | for db in 'nodes.user nodes.user.db'.split(): |
49 | | - if os.path.exists(os.path.join(config.TRACKER_HOME, 'db', db)): |
| 49 | + if os.path.exists(os.path.join(config.DATABASE, db)): |
50 | 50 | return 1 |
51 | 51 | return 0 |
52 | 52 |
|
53 | 53 | def db_nuke(config): |
54 | | - shutil.rmtree(os.path.join(config.TRACKER_HOME, 'db')) |
| 54 | + shutil.rmtree(config.DATABASE) |
55 | 55 |
|
56 | 56 | # |
57 | 57 | # Now the database |
@@ -185,6 +185,12 @@ def clear(self): |
185 | 185 | os.remove(path) |
186 | 186 | elif os.path.exists(path+'.db'): # dbm appends .db |
187 | 187 | os.remove(path+'.db') |
| 188 | + # reset id sequences |
| 189 | + path = os.path.join(os.getcwd(), self.dir, '_ids') |
| 190 | + if os.path.exists(path): |
| 191 | + os.remove(path) |
| 192 | + elif os.path.exists(path+'.db'): # dbm appends .db |
| 193 | + os.remove(path+'.db') |
188 | 194 |
|
189 | 195 | def getclassdb(self, classname, mode='r'): |
190 | 196 | ''' grab a connection to the class db that will be used for |
|
0 commit comments