Updated ChannelDBHandler to always return a new database if self.threaded is True.

This commit is contained in:
Jeremy Fincher 2003-08-23 12:38:58 +00:00
parent ade09765bc
commit 5769e4d4cf

View File

@ -23,6 +23,7 @@ class ChannelDBHandler(object):
"""A class to handle database stuff for individual channels transparently.
"""
suffix = '.db'
threaded = False
def __init__(self, suffix='.db'):
self.dbCache = ircutils.IrcDict()
suffix = self.suffix
@ -40,9 +41,13 @@ class ChannelDBHandler(object):
def getDb(self, channel):
try:
if self.threaded:
return self.makeDb(self.makeFilename(channel))
else:
return self.dbCache[channel]
except KeyError:
db = self.makeDb(self.makeFilename(channel))
if not self.threaded:
self.dbCache[channel] = db
return db