index 61ed0619e1cb522ea95fa92eb688c7ade6ed4fae..6f8edd7112c1bafcab95999ad2751745251d093c 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-#$Id: back_bsddb.py,v 1.14 2002-01-22 07:21:13 richard Exp $
+#$Id: back_bsddb.py,v 1.18 2002-05-15 06:21:21 richard Exp $
'''
This module defines a backend that saves the hyperdatabase in BSDDB.
'''
import bsddb, os, marshal
'''
This module defines a backend that saves the hyperdatabase in BSDDB.
'''
import bsddb, os, marshal
-from roundup import hyperdb, date, password
+from roundup import hyperdb, date
# these classes are so similar, we just use the anydbm methods
import back_anydbm
# these classes are so similar, we just use the anydbm methods
import back_anydbm
'''Low-level database opener that gets around anydbm/dbm
eccentricities.
'''
'''Low-level database opener that gets around anydbm/dbm
eccentricities.
'''
- if hyperdb.DEBUG:
- print self, '_opendb', (self, name, mode)
+ if __debug__:
+ print >>hyperdb.DEBUG, self, '_opendb', (self, name, mode)
# determine which DB wrote the class file
path = os.path.join(os.getcwd(), self.dir, name)
if not os.path.exists(path):
# determine which DB wrote the class file
path = os.path.join(os.getcwd(), self.dir, name)
if not os.path.exists(path):
- if hyperdb.DEBUG:
- print "_opendb bsddb.open(%r, 'n')"%path
+ if __debug__:
+ print >>hyperdb.DEBUG, "_opendb bsddb.open(%r, 'n')"%path
return bsddb.btopen(path, 'n')
# open the database with the correct module
return bsddb.btopen(path, 'n')
# open the database with the correct module
- if hyperdb.DEBUG:
- print "_opendb bsddb.open(%r, %r)"%(path, mode)
+ if __debug__:
+ print >>hyperdb.DEBUG, "_opendb bsddb.open(%r, %r)"%(path, mode)
return bsddb.btopen(path, mode)
#
return bsddb.btopen(path, mode)
#
journal = marshal.loads(db[nodeid])
res = []
for entry in journal:
journal = marshal.loads(db[nodeid])
res = []
for entry in journal:
- (nodeid, date_stamp, self.journaltag, action, params) = entry
+ (nodeid, date_stamp, user, action, params) = entry
date_obj = date.Date(date_stamp)
date_obj = date.Date(date_stamp)
- res.append((nodeid, date_obj, self.journaltag, action, params))
+ res.append((nodeid, date_obj, user, action, params))
db.close()
return res
def _doSaveJournal(self, classname, nodeid, action, params):
db.close()
return res
def _doSaveJournal(self, classname, nodeid, action, params):
+ # serialise first
+ if action in ('set', 'create'):
+ params = self.serialise(classname, params)
+
entry = (nodeid, date.Date().get_tuple(), self.journaltag, action,
params)
entry = (nodeid, date.Date().get_tuple(), self.journaltag, action,
params)
+
+ if __debug__:
+ print >>hyperdb.DEBUG, '_doSaveJournal', entry
+
db = bsddb.btopen(os.path.join(self.dir, 'journals.%s'%classname), 'c')
db = bsddb.btopen(os.path.join(self.dir, 'journals.%s'%classname), 'c')
+
if db.has_key(nodeid):
s = db[nodeid]
if db.has_key(nodeid):
s = db[nodeid]
- l = marshal.loads(db[nodeid])
+ l = marshal.loads(s)
l.append(entry)
else:
l = [entry]
l.append(entry)
else:
l = [entry]
+
db[nodeid] = marshal.dumps(l)
db.close()
#
#$Log: not supported by cvs2svn $
db[nodeid] = marshal.dumps(l)
db.close()
#
#$Log: not supported by cvs2svn $
+#Revision 1.17 2002/04/03 05:54:31 richard
+#Fixed serialisation problem by moving the serialisation step out of the
+#hyperdb.Class (get, set) into the hyperdb.Database.
+#
+#Also fixed htmltemplate after the showid changes I made yesterday.
+#
+#Unit tests for all of the above written.
+#
+#Revision 1.16 2002/02/27 03:40:59 richard
+#Ran it through pychecker, made fixes
+#
+#Revision 1.15 2002/02/16 09:15:33 richard
+#forgot to patch bsddb backend too
+#
+#Revision 1.14 2002/01/22 07:21:13 richard
+#. fixed back_bsddb so it passed the journal tests
+#
+#... it didn't seem happy using the back_anydbm _open method, which is odd.
+#Yet another occurrance of whichdb not being able to recognise older bsddb
+#databases. Yadda yadda. Made the HYPERDBDEBUG stuff more sane in the
+#process.
+#
#Revision 1.13 2001/12/10 22:20:01 richard
#Enabled transaction support in the bsddb backend. It uses the anydbm code
#where possible, only replacing methods where the db is opened (it uses the
#Revision 1.13 2001/12/10 22:20:01 richard
#Enabled transaction support in the bsddb backend. It uses the anydbm code
#where possible, only replacing methods where the db is opened (it uses the