From: richard Date: Mon, 30 Jul 2001 02:36:23 +0000 (+0000) Subject: Handle non-existence of db files in the other backends (code from anydbm). X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c8168b8ba8dd8a5a38db6ef2dac428438cf43def;p=roundup.git Handle non-existence of db files in the other backends (code from anydbm). git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@158 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/backends/back_bsddb.py b/roundup/backends/back_bsddb.py index fde8610..06e321e 100644 --- a/roundup/backends/back_bsddb.py +++ b/roundup/backends/back_bsddb.py @@ -1,4 +1,4 @@ -#$Id: back_bsddb.py,v 1.5 2001-07-30 01:41:36 richard Exp $ +#$Id: back_bsddb.py,v 1.6 2001-07-30 02:36:23 richard Exp $ import bsddb, os, marshal from roundup import hyperdb, date @@ -66,7 +66,10 @@ class Database(hyperdb.Database): multiple actions ''' path = os.path.join(os.getcwd(), self.dir, 'nodes.%s'%classname) - return bsddb.btopen(path, mode) + if os.path.exists(path): + return bsddb.btopen(path, mode) + else: + return bsddb.btopen(path, 'n') # # Nodes @@ -199,6 +202,9 @@ class Database(hyperdb.Database): # #$Log: not supported by cvs2svn $ +#Revision 1.5 2001/07/30 01:41:36 richard +#Makes schema changes mucho easier. +# #Revision 1.4 2001/07/23 08:25:33 richard #more handling of bad journals # diff --git a/roundup/backends/back_bsddb3.py b/roundup/backends/back_bsddb3.py index 581e7bc..9c14e3f 100644 --- a/roundup/backends/back_bsddb3.py +++ b/roundup/backends/back_bsddb3.py @@ -1,4 +1,4 @@ -#$Id: back_bsddb3.py,v 1.2 2001-07-30 01:41:36 richard Exp $ +#$Id: back_bsddb3.py,v 1.3 2001-07-30 02:36:23 richard Exp $ import bsddb3, os, marshal from roundup import hyperdb, date @@ -66,7 +66,10 @@ class Database(hyperdb.Database): multiple actions ''' path = os.path.join(os.getcwd(), self.dir, 'nodes.%s'%classname) - return bsddb3.btopen(path, mode) + if os.path.exists(path): + return bsddb3.btopen(path, mode) + else: + return bsddb3.btopen(path, 'n') # # Nodes @@ -199,6 +202,9 @@ class Database(hyperdb.Database): # #$Log: not supported by cvs2svn $ +#Revision 1.2 2001/07/30 01:41:36 richard +#Makes schema changes mucho easier. +# #Revision 1.1 2001/07/24 04:26:03 anthonybaxter #bsddb3 implementation. For now, it's the bsddb implementation with a "3" #added in crayon.