[Spambayes-checkins] spambayes/spambayes storage.py,1.28,1.29
Mark Hammond
mhammond at users.sourceforge.net
Tue Sep 9 00:17:36 EDT 2003
Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv29384
Modified Files:
storage.py
Log Message:
Add a close method to the various storage classes.
Index: storage.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/storage.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** storage.py 5 Sep 2003 01:15:28 -0000 1.28
--- storage.py 9 Sep 2003 06:17:33 -0000 1.29
***************
*** 141,144 ****
--- 141,148 ----
fp.close()
+ def close(self):
+ # we keep no reasources open - nothing to do
+ pass
+
# Values for our changed words map
WORD_DELETED = "D"
***************
*** 157,160 ****
--- 161,172 ----
self.load()
+ def close(self):
+ # Close our underlying database. Better not assume all databases
+ # have close functions!
+ def noop(): pass
+ getattr(self.db, "close", noop)()
+ getattr(self.dbm, "close", noop)()
+ # should not be a need to drop the 'dbm' or 'db' attributes.
+
def load(self):
'''Load state from database'''
***************
*** 292,295 ****
--- 304,313 ----
self.db_name = db_name
self.load()
+
+ def close(self):
+ '''Release all database resources'''
+ # As we (presumably) aren't as constrained as we are by file locking,
+ # don't force sub-classes to override
+ pass
def load(self):
More information about the Spambayes-checkins
mailing list