diff roundup/backends/back_anydbm.py @ 2608:151ee7f0ca7d

fix another bug exposed by earlier change to defaulting of *dbm property values
author Richard Jones <richard@users.sourceforge.net>
date Wed, 21 Jul 2004 01:01:44 +0000
parents 17eb5aeada7f
children 33fffbf7ae68
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py	Wed Jul 21 00:51:21 2004 +0000
+++ b/roundup/backends/back_anydbm.py	Wed Jul 21 01:01:44 2004 +0000
@@ -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.164 2004-07-21 00:51:21 richard Exp $
+#$Id: back_anydbm.py,v 1.165 2004-07-21 01:01:44 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
 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -1027,6 +1027,13 @@
         '''
         self.fireAuditors('set', nodeid, propvalues)
         oldvalues = copy.deepcopy(self.db.getnode(self.classname, nodeid))
+        for name,prop in self.getprops(protected=0).items():
+            if oldvalues.has_key(name):
+                continue
+            if isinstance(prop, Multilink):
+                oldvalues[name] = []
+            else:
+                oldvalues[name] = None
         propvalues = self.set_inner(nodeid, **propvalues)
         self.fireReactors('set', nodeid, oldvalues)
         return propvalues        
@@ -2084,7 +2091,16 @@
         ''' Snarf the "content" propvalue and update it in a file
         '''
         self.fireAuditors('set', itemid, propvalues)
+
+        # create the oldvalues dict - fill in any missing values
         oldvalues = copy.deepcopy(self.db.getnode(self.classname, itemid))
+        for name,prop in self.getprops(protected=0).items():
+            if oldvalues.has_key(name):
+                continue
+            if isinstance(prop, Multilink):
+                oldvalues[name] = []
+            else:
+                oldvalues[name] = None
 
         # now remove the content property so it's not stored in the db
         content = None

Roundup Issue Tracker: http://roundup-tracker.org/