|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -#$Id: back_anydbm.py,v 1.146.2.16 2004-07-21 00:51:49 richard Exp $ |
| 18 | +#$Id: back_anydbm.py,v 1.146.2.17 2004-07-21 01:02:15 richard Exp $ |
19 | 19 | '''This module defines a backend that saves the hyperdatabase in a |
20 | 20 | database chosen by anydbm. It is guaranteed to always be available in python |
21 | 21 | versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several |
@@ -1074,6 +1074,13 @@ class or a KeyError is raised. |
1074 | 1074 | ''' |
1075 | 1075 | self.fireAuditors('set', nodeid, propvalues) |
1076 | 1076 | oldvalues = copy.deepcopy(self.db.getnode(self.classname, nodeid)) |
| 1077 | + for name,prop in self.getprops(protected=0).items(): |
| 1078 | + if oldvalues.has_key(name): |
| 1079 | + continue |
| 1080 | + if isinstance(prop, Multilink): |
| 1081 | + oldvalues[name] = [] |
| 1082 | + else: |
| 1083 | + oldvalues[name] = None |
1077 | 1084 | propvalues = self.set_inner(nodeid, **propvalues) |
1078 | 1085 | self.fireReactors('set', nodeid, oldvalues) |
1079 | 1086 | return propvalues |
@@ -2134,7 +2141,16 @@ def set(self, itemid, **propvalues): |
2134 | 2141 | ''' Snarf the "content" propvalue and update it in a file |
2135 | 2142 | ''' |
2136 | 2143 | self.fireAuditors('set', itemid, propvalues) |
| 2144 | + |
| 2145 | + # create the oldvalues dict - fill in any missing values |
2137 | 2146 | oldvalues = copy.deepcopy(self.db.getnode(self.classname, itemid)) |
| 2147 | + for name,prop in self.getprops(protected=0).items(): |
| 2148 | + if oldvalues.has_key(name): |
| 2149 | + continue |
| 2150 | + if isinstance(prop, Multilink): |
| 2151 | + oldvalues[name] = [] |
| 2152 | + else: |
| 2153 | + oldvalues[name] = None |
2138 | 2154 |
|
2139 | 2155 | # now remove the content property so it's not stored in the db |
2140 | 2156 | content = None |
|
0 commit comments