1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- #$Id: back_anydbm.py,v 1.123 2003-08-26 00:06:55 richard Exp $
18+ #$Id: back_anydbm.py,v 1.124 2003-09-04 00:47:01 richard Exp $
1919'''
2020This module defines a backend that saves the hyperdatabase in a database
2121chosen by anydbm. It is guaranteed to always be available in python
@@ -283,17 +283,20 @@ def savenode(self, classname, nodeid, node):
283283
284284 def getnode (self , classname , nodeid , db = None , cache = 1 ):
285285 ''' get a node from the database
286+
287+ Note the "cache" parameter is not used, and exists purely for
288+ backward compatibility!
286289 '''
287290 if __debug__ :
288291 print >> hyperdb .DEBUG , 'getnode' , (self , classname , nodeid , db )
289- if cache :
290- # try the cache
291- cache_dict = self .cache .setdefault (classname , {})
292- if cache_dict .has_key (nodeid ):
293- if __debug__ :
294- print >> hyperdb .TRACE , 'get %s %s cached' % (classname ,
295- nodeid )
296- return cache_dict [nodeid ]
292+
293+ # try the cache
294+ cache_dict = self .cache .setdefault (classname , {})
295+ if cache_dict .has_key (nodeid ):
296+ if __debug__ :
297+ print >> hyperdb .TRACE , 'get %s %s cached' % (classname ,
298+ nodeid )
299+ return cache_dict [nodeid ]
297300
298301 if __debug__ :
299302 print >> hyperdb .TRACE , 'get %s %s' % (classname , nodeid )
@@ -1008,10 +1011,7 @@ def get(self, nodeid, propname, default=_marker, cache=1):
10081011 IndexError is raised. 'propname' must be the name of a property
10091012 of this class or a KeyError is raised.
10101013
1011- 'cache' indicates whether the transaction cache should be queried
1012- for the node. If the node has been modified and you need to
1013- determine what its values prior to modification are, you need to
1014- set cache=0.
1014+ 'cache' exists for backward compatibility, and is not used.
10151015
10161016 Attempts to get the "creation" or "activity" properties should
10171017 do the right thing.
@@ -1020,7 +1020,7 @@ def get(self, nodeid, propname, default=_marker, cache=1):
10201020 return nodeid
10211021
10221022 # get the node's dict
1023- d = self .db .getnode (self .classname , nodeid , cache = cache )
1023+ d = self .db .getnode (self .classname , nodeid )
10241024
10251025 # check for one of the special props
10261026 if propname == 'creation' :
@@ -1091,12 +1091,9 @@ def getnode(self, nodeid, cache=1):
10911091 'nodeid' must be the id of an existing node of this class or an
10921092 IndexError is raised.
10931093
1094- 'cache' indicates whether the transaction cache should be queried
1095- for the node. If the node has been modified and you need to
1096- determine what its values prior to modification are, you need to
1097- set cache=0.
1094+ 'cache' exists for backwards compatibility, and is not used.
10981095 '''
1099- return Node (self , nodeid , cache = cache )
1096+ return Node (self , nodeid )
11001097
11011098 def set (self , nodeid , ** propvalues ):
11021099 '''Modify a property on an existing node of this class.
@@ -1134,14 +1131,7 @@ class or a KeyError is raised.
11341131 self .fireAuditors ('set' , nodeid , propvalues )
11351132 # Take a copy of the node dict so that the subsequent set
11361133 # operation doesn't modify the oldvalues structure.
1137- try :
1138- # try not using the cache initially
1139- oldvalues = copy .deepcopy (self .db .getnode (self .classname , nodeid ,
1140- cache = 0 ))
1141- except IndexError :
1142- # this will be needed if somone does a create() and set()
1143- # with no intervening commit()
1144- oldvalues = copy .deepcopy (self .db .getnode (self .classname , nodeid ))
1134+ oldvalues = copy .deepcopy (self .db .getnode (self .classname , nodeid ))
11451135
11461136 node = self .db .getnode (self .classname , nodeid )
11471137 if node .has_key (self .db .RETIRED_FLAG ):
@@ -2040,7 +2030,9 @@ def import_list(self, propnames, proplist):
20402030 return newid
20412031
20422032 def get (self , nodeid , propname , default = _marker , cache = 1 ):
2043- ''' trap the content propname and get it from the file
2033+ ''' Trap the content propname and get it from the file
2034+
2035+ 'cache' exists for backwards compatibility, and is not used.
20442036 '''
20452037 poss_msg = 'Possibly an access right configuration problem.'
20462038 if propname == 'content' :
@@ -2051,9 +2043,9 @@ def get(self, nodeid, propname, default=_marker, cache=1):
20512043 return 'ERROR reading file: %s%s\n %s\n %s' % (
20522044 self .classname , nodeid , poss_msg , strerror )
20532045 if default is not _marker :
2054- return Class .get (self , nodeid , propname , default , cache = cache )
2046+ return Class .get (self , nodeid , propname , default )
20552047 else :
2056- return Class .get (self , nodeid , propname , cache = cache )
2048+ return Class .get (self , nodeid , propname )
20572049
20582050 def getprops (self , protected = 1 ):
20592051 ''' In addition to the actual properties on the node, these methods
0 commit comments