Skip to content

Commit 250ed15

Browse files
author
Richard Jones
committed
Handle non-existence of db files in the other backends (code from anydbm).
1 parent a437449 commit 250ed15

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

roundup/backends/back_bsddb.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: back_bsddb.py,v 1.5 2001-07-30 01:41:36 richard Exp $
1+
#$Id: back_bsddb.py,v 1.6 2001-07-30 02:36:23 richard Exp $
22

33
import bsddb, os, marshal
44
from roundup import hyperdb, date
@@ -66,7 +66,10 @@ def getclassdb(self, classname, mode='r'):
6666
multiple actions
6767
'''
6868
path = os.path.join(os.getcwd(), self.dir, 'nodes.%s'%classname)
69-
return bsddb.btopen(path, mode)
69+
if os.path.exists(path):
70+
return bsddb.btopen(path, mode)
71+
else:
72+
return bsddb.btopen(path, 'n')
7073

7174
#
7275
# Nodes
@@ -199,6 +202,9 @@ def rollback(self):
199202

200203
#
201204
#$Log: not supported by cvs2svn $
205+
#Revision 1.5 2001/07/30 01:41:36 richard
206+
#Makes schema changes mucho easier.
207+
#
202208
#Revision 1.4 2001/07/23 08:25:33 richard
203209
#more handling of bad journals
204210
#

roundup/backends/back_bsddb3.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: back_bsddb3.py,v 1.2 2001-07-30 01:41:36 richard Exp $
1+
#$Id: back_bsddb3.py,v 1.3 2001-07-30 02:36:23 richard Exp $
22

33
import bsddb3, os, marshal
44
from roundup import hyperdb, date
@@ -66,7 +66,10 @@ def getclassdb(self, classname, mode='r'):
6666
multiple actions
6767
'''
6868
path = os.path.join(os.getcwd(), self.dir, 'nodes.%s'%classname)
69-
return bsddb3.btopen(path, mode)
69+
if os.path.exists(path):
70+
return bsddb3.btopen(path, mode)
71+
else:
72+
return bsddb3.btopen(path, 'n')
7073

7174
#
7275
# Nodes
@@ -199,6 +202,9 @@ def rollback(self):
199202

200203
#
201204
#$Log: not supported by cvs2svn $
205+
#Revision 1.2 2001/07/30 01:41:36 richard
206+
#Makes schema changes mucho easier.
207+
#
202208
#Revision 1.1 2001/07/24 04:26:03 anthonybaxter
203209
#bsddb3 implementation. For now, it's the bsddb implementation with a "3"
204210
#added in crayon.

0 commit comments

Comments
 (0)