X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=roundup%2Fbackends%2Fback_bsddb3.py;h=5892a2cb1a5b6c3645d3977c708c2b673f632008;hb=3e236cbcab0a816b8eabfafe59443c8aefd5cc2c;hp=46b693c1a1a5a1b1e6fa29e2db7690f884524b2a;hpb=d41bd8697d416b2ae31bce688a72fc67f97a89f1;p=roundup.git diff --git a/roundup/backends/back_bsddb3.py b/roundup/backends/back_bsddb3.py index 46b693c..5892a2c 100644 --- a/roundup/backends/back_bsddb3.py +++ b/roundup/backends/back_bsddb3.py @@ -15,10 +15,10 @@ # 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 @@ -26,9 +26,10 @@ from roundup import hyperdb, date 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 @@ -39,7 +40,8 @@ class Database(hyperdb.Database): 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 = {} # @@ -95,15 +97,6 @@ class Database(hyperdb.Database): ''' 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() @@ -116,15 +109,6 @@ class Database(hyperdb.Database): 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 @@ -198,7 +182,7 @@ class Database(hyperdb.Database): we can be del'ed and the underlying bsddb connections closed cleanly. ''' - self.classes = None + self.classes = {} # @@ -219,6 +203,25 @@ class Database(hyperdb.Database): # #$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.