summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 728c61d)
raw | patch | inline | side by side (parent: 728c61d)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 22 Jan 2002 07:21:13 +0000 (07:21 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 22 Jan 2002 07:21:13 +0000 (07:21 +0000) |
... 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.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@582 57a73879-2fb5-44c3-a270-3262357dd7e2
Yet another occurrance of whichdb not being able to recognise older bsddb
databases. Yadda yadda. Made the HYPERDBDEBUG stuff more sane in the
process.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@582 57a73879-2fb5-44c3-a270-3262357dd7e2
diff --git a/CHANGES.txt b/CHANGES.txt
index 8e66a260f021d7587b732659125efd7425265000..d2d9add6e61e2bc52f4f86a0ff0b30958b64cbd2 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
Fixed:
. handle attachments with no name (eg tnef)
. fixed setting nosy as argument in subject line
-
+ . fixed back_bsddb so it passed the journal tests
2002-01-16 - 0.4.0b2
Fixed:
index b7e16155d2dd9b5f3622efded54a64e213147dd5..80603f3cbc43ebbcb5c943a3747f3168c9b72eda 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-#$Id: back_anydbm.py,v 1.26 2002-01-22 05:18:38 rochecompaan Exp $
+#$Id: back_anydbm.py,v 1.27 2002-01-22 07:21:13 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
import whichdb, anydbm, os, marshal
from roundup import hyperdb, date, password
-DEBUG=os.environ.get('HYPERDBDEBUG', '')
-
#
# Now the database
#
def __getattr__(self, classname):
"""A convenient way of calling self.getclass(classname)."""
if self.classes.has_key(classname):
- if DEBUG:
+ if hyperdb.DEBUG:
print '__getattr__', (self, classname)
return self.classes[classname]
raise AttributeError, classname
def addclass(self, cl):
- if DEBUG:
+ if hyperdb.DEBUG:
print 'addclass', (self, cl)
cn = cl.classname
if self.classes.has_key(cn):
def getclasses(self):
"""Return a list of the names of all existing classes."""
- if DEBUG:
+ if hyperdb.DEBUG:
print 'getclasses', (self,)
l = self.classes.keys()
l.sort()
If 'classname' is not a valid class name, a KeyError is raised.
"""
- if DEBUG:
+ if hyperdb.DEBUG:
print 'getclass', (self, classname)
return self.classes[classname]
def clear(self):
'''Delete all database contents
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'clear', (self,)
for cn in self.classes.keys():
for type in 'nodes', 'journals':
''' grab a connection to the class db that will be used for
multiple actions
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'getclassdb', (self, classname, mode)
return self._opendb('nodes.%s'%classname, mode)
'''Low-level database opener that gets around anydbm/dbm
eccentricities.
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print '_opendb', (self, name, mode)
# determine which DB wrote the class file
db_type = ''
# new database? let anydbm pick the best dbm
if not db_type:
- if DEBUG:
+ if hyperdb.DEBUG:
print "_opendb anydbm.open(%r, 'n')"%path
return anydbm.open(path, 'n')
raise hyperdb.DatabaseError, \
"Couldn't open database - the required module '%s'"\
"is not available"%db_type
- if DEBUG:
+ if hyperdb.DEBUG:
print "_opendb %r.open(%r, %r)"%(db_type, path, mode)
return dbm.open(path, mode)
def addnode(self, classname, nodeid, node):
''' add the specified node to its class's db
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'addnode', (self, classname, nodeid, node)
self.newnodes.setdefault(classname, {})[nodeid] = 1
self.cache.setdefault(classname, {})[nodeid] = node
def setnode(self, classname, nodeid, node):
''' change the specified node
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'setnode', (self, classname, nodeid, node)
self.dirtynodes.setdefault(classname, {})[nodeid] = 1
# can't set without having already loaded the node
def savenode(self, classname, nodeid, node):
''' perform the saving of data specified by the set/addnode
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'savenode', (self, classname, nodeid, node)
self.transactions.append((self._doSaveNode, (classname, nodeid, node)))
def getnode(self, classname, nodeid, db=None, cache=1):
''' get a node from the database
'''
- if DEBUG:
- print 'getnode', (self, classname, nodeid, cldb)
+ if hyperdb.DEBUG:
+ print 'getnode', (self, classname, nodeid, db)
if cache:
# try the cache
cache = self.cache.setdefault(classname, {})
def hasnode(self, classname, nodeid, db=None):
''' determine if the database has a given node
'''
- if DEBUG:
- print 'hasnode', (self, classname, nodeid, cldb)
+ if hyperdb.DEBUG:
+ print 'hasnode', (self, classname, nodeid, db)
# try the cache
cache = self.cache.setdefault(classname, {})
if cache.has_key(nodeid):
return res
def countnodes(self, classname, db=None):
- if DEBUG:
- print 'countnodes', (self, classname, cldb)
+ if hyperdb.DEBUG:
+ print 'countnodes', (self, classname, db)
# include the new nodes not saved to the DB yet
count = len(self.newnodes.get(classname, {}))
return count
def getnodeids(self, classname, db=None):
- if DEBUG:
+ if hyperdb.DEBUG:
print 'getnodeids', (self, classname, db)
# start off with the new nodes
res = self.newnodes.get(classname, {}).keys()
'link' or 'unlink' -- 'params' is (classname, nodeid, propname)
'retire' -- 'params' is None
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'addjournal', (self, classname, nodeid, action, params)
self.transactions.append((self._doSaveJournal, (classname, nodeid,
action, params)))
def getjournal(self, classname, nodeid):
''' get the journal for id
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'getjournal', (self, classname, nodeid)
# attempt to open the journal - in some rare cases, the journal may
# not exist
def pack(self, pack_before):
''' delete all journal entries before 'pack_before' '''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'packjournal', (self, pack_before)
pack_before = pack_before.get_tuple()
def commit(self):
''' Commit the current transactions.
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'commit', (self,)
# TODO: lock the DB
self.transactions = []
def _doSaveNode(self, classname, nodeid, node):
- if DEBUG:
+ if hyperdb.DEBUG:
print '_doSaveNode', (self, classname, nodeid, node)
# get the database handle
db[nodeid] = marshal.dumps(node)
def _doSaveJournal(self, classname, nodeid, action, params):
- if DEBUG:
+ if hyperdb.DEBUG:
print '_doSaveJournal', (self, classname, nodeid, action, params)
entry = (nodeid, date.Date().get_tuple(), self.journaltag, action,
params)
def rollback(self):
''' Reverse all actions from the current transaction.
'''
- if DEBUG:
+ if hyperdb.DEBUG:
print 'rollback', (self, )
for method, args in self.transactions:
# delete temporary files
#
#$Log: not supported by cvs2svn $
+#Revision 1.26 2002/01/22 05:18:38 rochecompaan
+#last_set_entry was referenced before assignment
+#
#Revision 1.25 2002/01/22 05:06:08 rochecompaan
#We need to keep the last 'set' entry in the journal to preserve
#information on 'activity' for nodes.
index 9f62f572ea3d55d964942a9bd27682f679e45aa0..61ed0619e1cb522ea95fa92eb688c7ade6ed4fae 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-#$Id: back_bsddb.py,v 1.13 2001-12-10 22:20:01 richard Exp $
+#$Id: back_bsddb.py,v 1.14 2002-01-22 07:21:13 richard Exp $
'''
This module defines a backend that saves the hyperdatabase in BSDDB.
'''
else:
return bsddb.btopen(path, 'n')
+ def _opendb(self, name, mode):
+ '''Low-level database opener that gets around anydbm/dbm
+ eccentricities.
+ '''
+ if hyperdb.DEBUG:
+ print 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):
+ if hyperdb.DEBUG:
+ print "_opendb bsddb.open(%r, 'n')"%path
+ return bsddb.btopen(path, 'n')
+
+ # open the database with the correct module
+ if hyperdb.DEBUG:
+ print "_opendb bsddb.open(%r, %r)"%(path, mode)
+ return bsddb.btopen(path, mode)
+
#
# Journal
#
#
#$Log: not supported by cvs2svn $
+#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
+#btree opener specifically.)
+#Also cleaned up some change note generation.
+#Made the backends package work with pydoc too.
+#
#Revision 1.12 2001/11/21 02:34:18 richard
#Added a target version field to the extended issue schema
#
diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py
index 8a12af13add2e30984844e49a1cfd9499ad50992..e47c85a17584ebebcd362172cf3fa1437295f2a7 100644 (file)
--- a/roundup/hyperdb.py
+++ b/roundup/hyperdb.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: hyperdb.py,v 1.52 2002-01-21 16:33:19 rochecompaan Exp $
+# $Id: hyperdb.py,v 1.53 2002-01-22 07:21:13 richard Exp $
__doc__ = """
Hyperdatabase implementation, especially field types.
"""
# standard python modules
-import cPickle, re, string, weakref
+import cPickle, re, string, weakref, os
# roundup modules
import date, password
+DEBUG = os.environ.get('HYPERDBDEBUG', '')
#
# Types
#
# $Log: not supported by cvs2svn $
+# Revision 1.52 2002/01/21 16:33:19 rochecompaan
+# You can now use the roundup-admin tool to pack the database
+#
# Revision 1.51 2002/01/21 03:01:29 richard
# brief docco on the do_journal argument
#
diff --git a/test/test_db.py b/test/test_db.py
index 664dc56be73385ea3ba16e8f5ad49ab348042692..b96f166b20297f92b05f348dd50d46839164675e 100644 (file)
--- a/test/test_db.py
+++ b/test/test_db.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: test_db.py,v 1.17 2002-01-22 05:06:09 rochecompaan Exp $
+# $Id: test_db.py,v 1.18 2002-01-22 07:21:13 richard Exp $
import unittest, os, shutil
self.db.commit()
self.db.issue.set('1', status='3')
self.db.commit()
-
pack_before = date.Date(". + 1d")
self.db.pack(pack_before)
journal = self.db.getjournal('issue', '1')
#
# $Log: not supported by cvs2svn $
+# Revision 1.17 2002/01/22 05:06:09 rochecompaan
+# We need to keep the last 'set' entry in the journal to preserve
+# information on 'activity' for nodes.
+#
# Revision 1.16 2002/01/21 16:33:20 rochecompaan
# You can now use the roundup-admin tool to pack the database
#