Mercurial > p > roundup > code
diff roundup/backends/back_anydbm.py @ 562:62febbd7ffec
You can now use the roundup-admin tool to pack the database
| author | Roche Compaan <rochecompaan@users.sourceforge.net> |
|---|---|
| date | Mon, 21 Jan 2002 16:33:20 +0000 |
| parents | 10ee3427011f |
| children | 73af3e54c309 |
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py Mon Jan 21 11:05:48 2002 +0000 +++ b/roundup/backends/back_anydbm.py Mon Jan 21 16:33:20 2002 +0000 @@ -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.23 2002-01-18 04:32:04 richard Exp $ +#$Id: back_anydbm.py,v 1.24 2002-01-21 16:33:20 rochecompaan 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 @@ -320,6 +320,43 @@ res.append((nodeid, date_obj, self.journaltag, action, params)) return res + def pack(self, pack_before): + ''' delete all journal entries before 'pack_before' ''' + if DEBUG: + print 'packjournal', (self, pack_before) + + pack_before = pack_before.get_tuple() + + classes = self.getclasses() + + # TODO: factor this out to method - we're already doing it in + # _opendb. + db_type = '' + path = os.path.join(os.getcwd(), self.dir, classes[0]) + if os.path.exists(path): + db_type = whichdb.whichdb(path) + if not db_type: + raise hyperdb.DatabaseError, "Couldn't identify database type" + elif os.path.exists(path+'.db'): + db_type = 'dbm' + + for classname in classes: + db_name = 'journals.%s'%classname + db = self._opendb(db_name, 'w') + + for key in db.keys(): + journal = marshal.loads(db[key]) + l = [] + for entry in journal: + (nodeid, date_stamp, self.journaltag, action, + params) = entry + if date_stamp > pack_before or action == 'create': + l.append(entry) + db[key] = marshal.dumps(l) + if db_type == 'gdbm': + db.reorganize() + db.close() + # # Basic transaction support @@ -407,6 +444,10 @@ # #$Log: not supported by cvs2svn $ +#Revision 1.23 2002/01/18 04:32:04 richard +#Rollback was breaking because a message hadn't actually been written to the file. Needs +#more investigation. +# #Revision 1.22 2002/01/14 02:20:15 richard # . changed all config accesses so they access either the instance or the # config attriubute on the db. This means that all config is obtained from
