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.179.2.4 2005-02-13 22:40:53 richard Exp $
18+ #$Id: back_anydbm.py,v 1.179.2.5 2005-02-14 02:55:30 richard Exp $
1919'''This module defines a backend that saves the hyperdatabase in a
2020database chosen by anydbm. It is guaranteed to always be available in python
2121versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
3333except AssertionError :
3434 print "WARNING: you should upgrade to python 2.1.3"
3535
36- import whichdb , os , marshal , re , weakref , string , copy , time , shutil
36+ import whichdb , os , marshal , re , weakref , string , copy , time , shutil , logging
3737
3838from roundup import hyperdb , date , password , roundupdb , security
3939from roundup .backends import locking
@@ -177,7 +177,7 @@ def getclass(self, classname):
177177 def clear (self ):
178178 '''Delete all database contents
179179 '''
180- self . config . logging .getLogger ('hyperdb' ).info ('clear' )
180+ logging .getLogger ('hyperdb' ).info ('clear' )
181181 for cn in self .classes .keys ():
182182 for dummy in 'nodes' , 'journals' :
183183 path = os .path .join (self .dir , 'journals.%s' % cn )
@@ -223,7 +223,7 @@ def opendb(self, name, mode):
223223 # new database? let anydbm pick the best dbm
224224 if not db_type :
225225 if __debug__ :
226- self . config . logging .getLogger ('hyperdb' ).debug ("opendb anydbm.open(%r, 'c')" % path )
226+ logging .getLogger ('hyperdb' ).debug ("opendb anydbm.open(%r, 'c')" % path )
227227 return anydbm .open (path , 'c' )
228228
229229 # open the database with the correct module
@@ -234,7 +234,7 @@ def opendb(self, name, mode):
234234 "Couldn't open database - the required module '%s'" \
235235 " is not available" % db_type
236236 if __debug__ :
237- self . config . logging .getLogger ('hyperdb' ).debug ("opendb %r.open(%r, %r)" % (db_type , path ,
237+ logging .getLogger ('hyperdb' ).debug ("opendb %r.open(%r, %r)" % (db_type , path ,
238238 mode ))
239239 return dbm .open (path , mode )
240240
@@ -295,7 +295,7 @@ def savenode(self, classname, nodeid, node):
295295 ''' perform the saving of data specified by the set/addnode
296296 '''
297297 if __debug__ :
298- self . config . logging .getLogger ('hyperdb' ).debug ('save %s%s %r' % (classname , nodeid , node ))
298+ logging .getLogger ('hyperdb' ).debug ('save %s%s %r' % (classname , nodeid , node ))
299299 self .transactions .append ((self .doSaveNode , (classname , nodeid , node )))
300300
301301 def getnode (self , classname , nodeid , db = None , cache = 1 ):
@@ -308,14 +308,14 @@ def getnode(self, classname, nodeid, db=None, cache=1):
308308 cache_dict = self .cache .setdefault (classname , {})
309309 if cache_dict .has_key (nodeid ):
310310 if __debug__ :
311- self . config . logging .getLogger ('hyperdb' ).debug ('get %s%s cached' % (classname , nodeid ))
311+ logging .getLogger ('hyperdb' ).debug ('get %s%s cached' % (classname , nodeid ))
312312 self .stats ['cache_hits' ] += 1
313313 return cache_dict [nodeid ]
314314
315315 if __debug__ :
316316 self .stats ['cache_misses' ] += 1
317317 start_t = time .time ()
318- self . config . logging .getLogger ('hyperdb' ).debug ('get %s%s' % (classname , nodeid ))
318+ logging .getLogger ('hyperdb' ).debug ('get %s%s' % (classname , nodeid ))
319319
320320 # get from the database and save in the cache
321321 if db is None :
@@ -347,7 +347,7 @@ def destroynode(self, classname, nodeid):
347347 '''Remove a node from the database. Called exclusively by the
348348 destroy() method on Class.
349349 '''
350- self . config . logging .getLogger ('hyperdb' ).info ('destroy %s%s' % (classname , nodeid ))
350+ logging .getLogger ('hyperdb' ).info ('destroy %s%s' % (classname , nodeid ))
351351
352352 # remove from cache and newnodes if it's there
353353 if (self .cache .has_key (classname ) and
@@ -473,7 +473,7 @@ def addjournal(self, classname, nodeid, action, params, creator=None,
473473 the current user.
474474 '''
475475 if __debug__ :
476- self . config . logging .getLogger ('hyperdb' ).debug ('addjournal %s%s %s %r %s %r' % (classname ,
476+ logging .getLogger ('hyperdb' ).debug ('addjournal %s%s %s %r %s %r' % (classname ,
477477 nodeid , action , params , creator , creation ))
478478 if creator is None :
479479 creator = self .getuid ()
@@ -483,7 +483,7 @@ def addjournal(self, classname, nodeid, action, params, creator=None,
483483 def setjournal (self , classname , nodeid , journal ):
484484 '''Set the journal to the "journal" list.'''
485485 if __debug__ :
486- self . config . logging .getLogger ('hyperdb' ).debug ('setjournal %s%s %r' % (classname ,
486+ logging .getLogger ('hyperdb' ).debug ('setjournal %s%s %r' % (classname ,
487487 nodeid , journal ))
488488 self .transactions .append ((self .doSetJournal , (classname , nodeid ,
489489 journal )))
@@ -570,7 +570,7 @@ def pack(self, pack_before):
570570 packed += 1
571571 db [key ] = marshal .dumps (l )
572572
573- self . config . logging .getLogger ('hyperdb' ).info ('packed %d %s items' % (packed ,
573+ logging .getLogger ('hyperdb' ).info ('packed %d %s items' % (packed ,
574574 classname ))
575575
576576 if db_type == 'gdbm' :
@@ -584,7 +584,7 @@ def pack(self, pack_before):
584584 def commit (self ):
585585 ''' Commit the current transactions.
586586 '''
587- self . config . logging .getLogger ('hyperdb' ).info ('commit %s transactions' % (
587+ logging .getLogger ('hyperdb' ).info ('commit %s transactions' % (
588588 len (self .transactions )))
589589
590590 # keep a handle to all the database files opened
@@ -705,7 +705,7 @@ def doDestroyNode(self, classname, nodeid):
705705 def rollback (self ):
706706 ''' Reverse all actions from the current transaction.
707707 '''
708- self . config . logging .getLogger ('hyperdb' ).info ('rollback %s transactions' % (
708+ logging .getLogger ('hyperdb' ).info ('rollback %s transactions' % (
709709 len (self .transactions )))
710710
711711 for method , args in self .transactions :
0 commit comments