Code

Fixed a backlog of bug reports, and worked on python 2.3 compatibility:
[roundup.git] / roundup / backends / back_anydbm.py
index a199d1eb7629ba542998b22a6d5d7b2c9b824149..681698b389d29fe04aef13b101c938d224745e18 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: back_anydbm.py,v 1.95 2002-12-12 09:31:04 richard Exp $
+#$Id: back_anydbm.py,v 1.100 2003-02-06 05:43:47 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
@@ -555,7 +555,6 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database):
         '''
         if __debug__:
             print >>hyperdb.DEBUG, 'commit', (self,)
-        # TODO: lock the DB
 
         # keep a handle to all the database files opened
         self.databases = {}
@@ -569,7 +568,6 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database):
         for db in self.databases.values():
             db.close()
         del self.databases
-        # TODO: unlock the DB
 
         # reindex the nodes that request it
         for classname, nodeid in filter(None, reindex.keys()):
@@ -847,7 +845,7 @@ class Class(hyperdb.Class):
                             (self.classname, newid, key))
 
             elif isinstance(prop, String):
-                if type(value) != type(''):
+                if type(value) != type('') and type(value) != type(u''):
                     raise TypeError, 'new property "%s" not a string'%key
 
             elif isinstance(prop, Password):
@@ -1244,7 +1242,7 @@ class Class(hyperdb.Class):
                     journalvalues[propname] = tuple(l)
 
             elif isinstance(prop, String):
-                if value is not None and type(value) != type(''):
+                if value is not None and type(value) != type('') and type(value) != type(u''):
                     raise TypeError, 'new property "%s" not a string'%propname
 
             elif isinstance(prop, Password):
@@ -1349,7 +1347,7 @@ class Class(hyperdb.Class):
 
         The returned list contains tuples of the form
 
-            (date, tag, action, params)
+            (nodeid, date, tag, action, params)
 
         'date' is a Timestamp object specifying the time of the change and
         'tag' is the journaltag specified when the database was opened.
@@ -1603,6 +1601,10 @@ class Class(hyperdb.Class):
                 else:
                     bv = v
                 l.append((OTHER, k, bv))
+            elif isinstance(propclass, Date):
+                l.append((OTHER, k, date.Date(v)))
+            elif isinstance(propclass, Interval):
+                l.append((OTHER, k, date.Interval(v)))
             elif isinstance(propclass, Number):
                 l.append((OTHER, k, int(v)))
             else:
@@ -1758,12 +1760,15 @@ class Class(hyperdb.Class):
                 # Multilink properties are sorted according to how many
                 # links are present.
                 elif isinstance(propclass, Multilink):
+                    r = cmp(len(av), len(bv))
+                    if r == 0:
+                        # Compare contents of multilink property if lenghts is
+                        # equal
+                        r = cmp ('.'.join(av), '.'.join(bv))
                     if dir == '+':
-                        r = cmp(len(av), len(bv))
-                        if r != 0: return r
+                        return r
                     elif dir == '-':
-                        r = cmp(len(bv), len(av))
-                        if r != 0: return r
+                        return -r
                 elif isinstance(propclass, Number) or isinstance(propclass, Boolean):
                     if dir == '+':
                         r = cmp(av, bv)