Mercurial > p > roundup > code
comparison roundup/backends/rdbms_common.py @ 1304:61ad556cfc8d
working toward 0.5.2 release
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 06 Nov 2002 11:38:43 +0000 |
| parents | 9c3459cb8ab6 |
| children | 80d27b7d6db5 |
comparison
equal
deleted
inserted
replaced
| 1303:71be6588904f | 1304:61ad556cfc8d |
|---|---|
| 1 # $Id: rdbms_common.py,v 1.23 2002-10-31 04:02:23 richard Exp $ | 1 # $Id: rdbms_common.py,v 1.24 2002-11-06 11:38:42 richard Exp $ |
| 2 ''' Relational database (SQL) backend common code. | 2 ''' Relational database (SQL) backend common code. |
| 3 | 3 |
| 4 Basics: | 4 Basics: |
| 5 | 5 |
| 6 - map roundup classes to relational tables | 6 - map roundup classes to relational tables |
| 1100 propvalues[key] = None | 1100 propvalues[key] = None |
| 1101 | 1101 |
| 1102 # done | 1102 # done |
| 1103 self.db.addnode(self.classname, newid, propvalues) | 1103 self.db.addnode(self.classname, newid, propvalues) |
| 1104 if self.do_journal: | 1104 if self.do_journal: |
| 1105 self.db.addjournal(self.classname, newid, 'create', propvalues) | 1105 self.db.addjournal(self.classname, newid, 'create', {}) |
| 1106 | 1106 |
| 1107 self.fireReactors('create', newid, None) | 1107 self.fireReactors('create', newid, None) |
| 1108 | 1108 |
| 1109 return newid | 1109 return newid |
| 1110 | 1110 |
| 1182 del d['creation'] | 1182 del d['creation'] |
| 1183 else: | 1183 else: |
| 1184 creation = None | 1184 creation = None |
| 1185 if d.has_key('activity'): | 1185 if d.has_key('activity'): |
| 1186 del d['activity'] | 1186 del d['activity'] |
| 1187 self.db.addjournal(self.classname, newid, 'create', d, creator, | 1187 self.db.addjournal(self.classname, newid, 'create', {}, creator, |
| 1188 creation) | 1188 creation) |
| 1189 return newid | 1189 return newid |
| 1190 | 1190 |
| 1191 _marker = [] | 1191 _marker = [] |
| 1192 def get(self, nodeid, propname, default=_marker, cache=1): | 1192 def get(self, nodeid, propname, default=_marker, cache=1): |
| 1321 raise KeyError, '"%s" has no property named "%s"'%( | 1321 raise KeyError, '"%s" has no property named "%s"'%( |
| 1322 self.classname, propname) | 1322 self.classname, propname) |
| 1323 | 1323 |
| 1324 # if the value's the same as the existing value, no sense in | 1324 # if the value's the same as the existing value, no sense in |
| 1325 # doing anything | 1325 # doing anything |
| 1326 if node.has_key(propname) and value == node[propname]: | 1326 current = node.get(propname, None) |
| 1327 if value == current: | |
| 1327 del propvalues[propname] | 1328 del propvalues[propname] |
| 1328 continue | 1329 continue |
| 1330 journalvalues[propname] = current | |
| 1329 | 1331 |
| 1330 # do stuff based on the prop type | 1332 # do stuff based on the prop type |
| 1331 if isinstance(prop, Link): | 1333 if isinstance(prop, Link): |
| 1332 link_class = prop.classname | 1334 link_class = prop.classname |
| 1333 # if it isn't a number, it's a key | 1335 # if it isn't a number, it's a key |
| 1458 | 1460 |
| 1459 # do the set, and journal it | 1461 # do the set, and journal it |
| 1460 self.db.setnode(self.classname, nodeid, propvalues, multilink_changes) | 1462 self.db.setnode(self.classname, nodeid, propvalues, multilink_changes) |
| 1461 | 1463 |
| 1462 if self.do_journal: | 1464 if self.do_journal: |
| 1463 propvalues.update(journalvalues) | 1465 self.db.addjournal(self.classname, nodeid, 'set', journalvalues) |
| 1464 self.db.addjournal(self.classname, nodeid, 'set', propvalues) | |
| 1465 | 1466 |
| 1466 self.fireReactors('set', nodeid, oldvalues) | 1467 self.fireReactors('set', nodeid, oldvalues) |
| 1467 | 1468 |
| 1468 return propvalues | 1469 return propvalues |
| 1469 | 1470 |
