comparison roundup/backends/rdbms_common.py @ 1496:e6ac4e074acb

relaxed CVS importing (feature [SF#693277])
author Richard Jones <richard@users.sourceforge.net>
date Thu, 06 Mar 2003 07:33:29 +0000
parents 2fc7d4a8c9e7
children 8ee69708da0c
comparison
equal deleted inserted replaced
1495:a2a57ec8fdf0 1496:e6ac4e074acb
1 # $Id: rdbms_common.py,v 1.39 2003-03-06 06:03:51 richard Exp $ 1 # $Id: rdbms_common.py,v 1.40 2003-03-06 07:33:29 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
448 node['creation'] = node['activity'] = date.Date() 448 node['creation'] = node['activity'] = date.Date()
449 node['creator'] = self.curuserid 449 node['creator'] = self.curuserid
450 450
451 # default the non-multilink columns 451 # default the non-multilink columns
452 for col, prop in cl.properties.items(): 452 for col, prop in cl.properties.items():
453 if not isinstance(col, Multilink): 453 if not node.has_key(col):
454 if not node.has_key(col): 454 if isinstance(prop, Multilink):
455 node[col] = []
456 else:
455 node[col] = None 457 node[col] = None
456 458
457 # clear this node out of the cache if it's in there 459 # clear this node out of the cache if it's in there
458 key = (classname, nodeid) 460 key = (classname, nodeid)
459 if self.cache.has_key(key): 461 if self.cache.has_key(key):
1098 raise DatabaseError, 'Database open read-only' 1100 raise DatabaseError, 'Database open read-only'
1099 properties = self.getprops() 1101 properties = self.getprops()
1100 1102
1101 # make the new node's property map 1103 # make the new node's property map
1102 d = {} 1104 d = {}
1105 retire = 0
1106 newid = None
1103 for i in range(len(propnames)): 1107 for i in range(len(propnames)):
1104 # Use eval to reverse the repr() used to output the CSV 1108 # Use eval to reverse the repr() used to output the CSV
1105 value = eval(proplist[i]) 1109 value = eval(proplist[i])
1106 1110
1107 # Figure the property for this column 1111 # Figure the property for this column
1108 propname = propnames[i] 1112 propname = propnames[i]
1109 prop = properties[propname]
1110 1113
1111 # "unmarshal" where necessary 1114 # "unmarshal" where necessary
1112 if propname == 'id': 1115 if propname == 'id':
1113 newid = value 1116 newid = value
1114 continue 1117 continue
1115 elif value is None: 1118 elif propname == 'is retired':
1119 # is the item retired?
1120 if int(value):
1121 retire = 1
1122 continue
1123
1124 prop = properties[propname]
1125 if value is None:
1116 # don't set Nones 1126 # don't set Nones
1117 continue 1127 continue
1118 elif isinstance(prop, hyperdb.Date): 1128 elif isinstance(prop, hyperdb.Date):
1119 value = date.Date(value) 1129 value = date.Date(value)
1120 elif isinstance(prop, hyperdb.Interval): 1130 elif isinstance(prop, hyperdb.Interval):
1123 pwd = password.Password() 1133 pwd = password.Password()
1124 pwd.unpack(value) 1134 pwd.unpack(value)
1125 value = pwd 1135 value = pwd
1126 d[propname] = value 1136 d[propname] = value
1127 1137
1138 # get a new id if necessary
1139 if newid is None:
1140 newid = self.db.newid(self.classname)
1141
1128 # retire? 1142 # retire?
1129 if int(proplist[-1]): 1143 if retire:
1130 # use the arg for __retired__ to cope with any odd database type 1144 # use the arg for __retired__ to cope with any odd database type
1131 # conversion (hello, sqlite) 1145 # conversion (hello, sqlite)
1132 sql = 'update _%s set __retired__=%s where id=%s'%(self.classname, 1146 sql = 'update _%s set __retired__=%s where id=%s'%(self.classname,
1133 self.db.arg, self.db.arg) 1147 self.db.arg, self.db.arg)
1134 if __debug__: 1148 if __debug__:

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