Mercurial > p > roundup > code
comparison roundup/backends/rdbms_common.py @ 1920:f9316d2cd5ba
Fixed retirement of items in rdbms imports [SF#841355]
Fixed bug in looking up journal of newly-created items in *dbm backends
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 14 Nov 2003 00:11:19 +0000 |
| parents | 2b0ab61db194 |
| children | 3bdd34547fa7 |
comparison
equal
deleted
inserted
replaced
| 1919:e90072582d41 | 1920:f9316d2cd5ba |
|---|---|
| 1 # $Id: rdbms_common.py,v 1.69 2003-11-12 03:42:12 richard Exp $ | 1 # $Id: rdbms_common.py,v 1.70 2003-11-14 00:11:19 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 |
| 1234 elif isinstance(proptype, hyperdb.Interval): | 1234 elif isinstance(proptype, hyperdb.Interval): |
| 1235 value = value.get_tuple() | 1235 value = value.get_tuple() |
| 1236 elif isinstance(proptype, hyperdb.Password): | 1236 elif isinstance(proptype, hyperdb.Password): |
| 1237 value = str(value) | 1237 value = str(value) |
| 1238 l.append(repr(value)) | 1238 l.append(repr(value)) |
| 1239 l.append(self.is_retired(nodeid)) | 1239 l.append(repr(self.is_retired(nodeid))) |
| 1240 return l | 1240 return l |
| 1241 | 1241 |
| 1242 def import_list(self, propnames, proplist): | 1242 def import_list(self, propnames, proplist): |
| 1243 ''' Import a node - all information including "id" is present and | 1243 ''' Import a node - all information including "id" is present and |
| 1244 should not be sanity checked. Triggers are not triggered. The | 1244 should not be sanity checked. Triggers are not triggered. The |
| 1291 | 1291 |
| 1292 # get a new id if necessary | 1292 # get a new id if necessary |
| 1293 if newid is None: | 1293 if newid is None: |
| 1294 newid = self.db.newid(self.classname) | 1294 newid = self.db.newid(self.classname) |
| 1295 | 1295 |
| 1296 # add the node and journal | |
| 1297 self.db.addnode(self.classname, newid, d) | |
| 1298 | |
| 1296 # retire? | 1299 # retire? |
| 1297 if retire: | 1300 if retire: |
| 1298 # use the arg for __retired__ to cope with any odd database type | 1301 # use the arg for __retired__ to cope with any odd database type |
| 1299 # conversion (hello, sqlite) | 1302 # conversion (hello, sqlite) |
| 1300 sql = 'update _%s set __retired__=%s where id=%s'%(self.classname, | 1303 sql = 'update _%s set __retired__=%s where id=%s'%(self.classname, |
| 1301 self.db.arg, self.db.arg) | 1304 self.db.arg, self.db.arg) |
| 1302 if __debug__: | 1305 if __debug__: |
| 1303 print >>hyperdb.DEBUG, 'retire', (self, sql, newid) | 1306 print >>hyperdb.DEBUG, 'retire', (self, sql, newid) |
| 1304 self.db.cursor.execute(sql, (1, newid)) | 1307 self.db.cursor.execute(sql, (1, newid)) |
| 1305 | |
| 1306 # add the node and journal | |
| 1307 self.db.addnode(self.classname, newid, d) | |
| 1308 | 1308 |
| 1309 # extract the extraneous journalling gumpf and nuke it | 1309 # extract the extraneous journalling gumpf and nuke it |
| 1310 if d.has_key('creator'): | 1310 if d.has_key('creator'): |
| 1311 creator = d['creator'] | 1311 creator = d['creator'] |
| 1312 del d['creator'] | 1312 del d['creator'] |
