comparison roundup/backends/rdbms_common.py @ 1780:d2801a2b0a77

Initial implementation (half-baked) at new Tracker instance. Cleaned up caching API / comments in backends. Fixes to docs.
author Richard Jones <richard@users.sourceforge.net>
date Thu, 04 Sep 2003 00:47:01 +0000
parents ab7760caf6ff
children 2724d14f0c42
comparison
equal deleted inserted replaced
1777:fbe08359511a 1780:d2801a2b0a77
1 # $Id: rdbms_common.py,v 1.59 2003-08-26 00:06:56 richard Exp $ 1 # $Id: rdbms_common.py,v 1.60 2003-09-04 00:47:01 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
1181 1181
1182 'nodeid' must be the id of an existing node of this class or an 1182 'nodeid' must be the id of an existing node of this class or an
1183 IndexError is raised. 'propname' must be the name of a property 1183 IndexError is raised. 'propname' must be the name of a property
1184 of this class or a KeyError is raised. 1184 of this class or a KeyError is raised.
1185 1185
1186 'cache' indicates whether the transaction cache should be queried 1186 'cache' exists for backwards compatibility, and is not used.
1187 for the node. If the node has been modified and you need to
1188 determine what its values prior to modification are, you need to
1189 set cache=0.
1190 ''' 1187 '''
1191 if propname == 'id': 1188 if propname == 'id':
1192 return nodeid 1189 return nodeid
1193 1190
1194 # get the node's dict 1191 # get the node's dict
1232 ''' Return a convenience wrapper for the node. 1229 ''' Return a convenience wrapper for the node.
1233 1230
1234 'nodeid' must be the id of an existing node of this class or an 1231 'nodeid' must be the id of an existing node of this class or an
1235 IndexError is raised. 1232 IndexError is raised.
1236 1233
1237 'cache' indicates whether the transaction cache should be queried 1234 'cache' exists for backwards compatibility, and is not used.
1238 for the node. If the node has been modified and you need to 1235 '''
1239 determine what its values prior to modification are, you need to 1236 return Node(self, nodeid)
1240 set cache=0.
1241 '''
1242 return Node(self, nodeid, cache=cache)
1243 1237
1244 def set(self, nodeid, **propvalues): 1238 def set(self, nodeid, **propvalues):
1245 '''Modify a property on an existing node of this class. 1239 '''Modify a property on an existing node of this class.
1246 1240
1247 'nodeid' must be the id of an existing node of this class or an 1241 'nodeid' must be the id of an existing node of this class or an
2092 self.db.storefile(self.classname, newid, None, content) 2086 self.db.storefile(self.classname, newid, None, content)
2093 return newid 2087 return newid
2094 2088
2095 _marker = [] 2089 _marker = []
2096 def get(self, nodeid, propname, default=_marker, cache=1): 2090 def get(self, nodeid, propname, default=_marker, cache=1):
2097 ''' trap the content propname and get it from the file 2091 ''' Trap the content propname and get it from the file
2092
2093 'cache' exists for backwards compatibility, and is not used.
2098 ''' 2094 '''
2099 poss_msg = 'Possibly a access right configuration problem.' 2095 poss_msg = 'Possibly a access right configuration problem.'
2100 if propname == 'content': 2096 if propname == 'content':
2101 try: 2097 try:
2102 return self.db.getfile(self.classname, nodeid, None) 2098 return self.db.getfile(self.classname, nodeid, None)
2103 except IOError, (strerror): 2099 except IOError, (strerror):
2104 # BUG: by catching this we donot see an error in the log. 2100 # BUG: by catching this we donot see an error in the log.
2105 return 'ERROR reading file: %s%s\n%s\n%s'%( 2101 return 'ERROR reading file: %s%s\n%s\n%s'%(
2106 self.classname, nodeid, poss_msg, strerror) 2102 self.classname, nodeid, poss_msg, strerror)
2107 if default is not self._marker: 2103 if default is not self._marker:
2108 return Class.get(self, nodeid, propname, default, cache=cache) 2104 return Class.get(self, nodeid, propname, default)
2109 else: 2105 else:
2110 return Class.get(self, nodeid, propname, cache=cache) 2106 return Class.get(self, nodeid, propname)
2111 2107
2112 def getprops(self, protected=1): 2108 def getprops(self, protected=1):
2113 ''' In addition to the actual properties on the node, these methods 2109 ''' In addition to the actual properties on the node, these methods
2114 provide the "content" property. If the "protected" flag is true, 2110 provide the "content" property. If the "protected" flag is true,
2115 we include protected properties - those which may not be 2111 we include protected properties - those which may not be

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