index 46b693c1a1a5a1b1e6fa29e2db7690f884524b2a..5892a2cb1a5b6c3645d3977c708c2b673f632008 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-#$Id: back_bsddb3.py,v 1.6 2001-08-07 00:24:42 richard Exp $
+#$Id: back_bsddb3.py,v 1.11 2002-01-14 02:20:15 richard Exp $
import bsddb3, os, marshal
-from roundup import hyperdb, date
+from roundup import hyperdb, date, password
#
# Now the database
class Database(hyperdb.Database):
"""A database for storing records containing flexible data types."""
- def __init__(self, storagelocator, journaltag=None):
+ def __init__(self, config, journaltag=None):
"""Open a hyperdatabase given a specifier to some storage.
+ The 'storagelocator' is obtained from config.DATABASE.
The meaning of 'storagelocator' depends on the particular
implementation of the hyperdatabase. It could be a file name,
a directory path, a socket descriptor for a connection to a
None, the database is opened in read-only mode: the Class.create(),
Class.set(), and Class.retire() methods are disabled.
"""
- self.dir, self.journaltag = storagelocator, journaltag
+ self.config, self.journaltag = config, journaltag
+ self.dir = config.DATABASE
self.classes = {}
#
''' add the specified node to its class's db
'''
db = self.getclassdb(classname, 'c')
-
- # convert the instance data to builtin types
- properties = self.classes[classname].properties
- for key in properties.keys():
- if properties[key].isDateType:
- node[key] = node[key].get_tuple()
- elif properties[key].isIntervalType:
- node[key] = node[key].get_tuple()
-
# now save the marshalled data
db[nodeid] = marshal.dumps(node)
db.close()
if not db.has_key(nodeid):
raise IndexError, nodeid
res = marshal.loads(db[nodeid])
-
- # convert the marshalled data to instances
- properties = self.classes[classname].properties
- for key in properties.keys():
- if properties[key].isDateType:
- res[key] = date.Date(res[key])
- elif properties[key].isIntervalType:
- res[key] = date.Interval(res[key])
-
if not cldb: db.close()
return res
we can be del'ed and the underlying bsddb connections closed
cleanly.
'''
- self.classes = None
+ self.classes = {}
#
#
#$Log: not supported by cvs2svn $
+#Revision 1.10 2001/11/21 02:34:18 richard
+#Added a target version field to the extended issue schema
+#
+#Revision 1.9 2001/10/09 23:58:10 richard
+#Moved the data stringification up into the hyperdb.Class class' get, set
+#and create methods. This means that the data is also stringified for the
+#journal call, and removes duplication of code from the backends. The
+#backend code now only sees strings.
+#
+#Revision 1.8 2001/10/09 07:25:59 richard
+#Added the Password property type. See "pydoc roundup.password" for
+#implementation details. Have updated some of the documentation too.
+#
+#Revision 1.7 2001/08/12 06:32:36 richard
+#using isinstance(blah, Foo) now instead of isFooType
+#
+#Revision 1.6 2001/08/07 00:24:42 richard
+#stupid typo
+#
#Revision 1.5 2001/08/07 00:15:51 richard
#Added the copyright/license notice to (nearly) all files at request of
#Bizar Software.