spambayes/spambayes storage.py,1.49,1.50

"Tony Meyer" <[email protected]>
Newsgroups gmane.mail.spam.spambayes.cvs
Message-ID <[email protected]>
Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12091/spambayes

Modified Files:
	storage.py 
Log Message:
Use the os.path.basename as the database name for a ZODB FileStorage database, so that if the database is moved it will still work.

(If it's renamed, it won't work - but maybe this is a good thing.  If anyone thinks that it isn't, then change the db name to "SpamBayes" or something.  The long term scheme is to put the messageinfo database (when needed) in the same FileStorage, but under a different dbname).

Index: storage.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/storage.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** storage.py	18 Mar 2005 01:37:22 -0000	1.49
--- storage.py	21 Apr 2005 07:16:48 -0000	1.50
***************
*** 672,676 ****
  class ZODBClassifier(object):
      def __init__(self, db_name):
!         self.db_name = db_name
          self.closed = True
          self.load()
--- 672,677 ----
  class ZODBClassifier(object):
      def __init__(self, db_name):
!         self.db_filename = db_name
!         self.db_name = os.path.basename(db_name)
          self.closed = True
          self.load()
***************
*** 693,697 ****
          import ZODB
          from ZODB.FileStorage import FileStorage
!         self.storage = FileStorage(self.db_name)
  
      def load(self):
--- 694,698 ----
          import ZODB
          from ZODB.FileStorage import FileStorage
!         self.storage = FileStorage(self.db_filename)
  
      def load(self):
***************
*** 700,704 ****
  
          if options["globals", "verbose"]:
!             print >> sys.stderr, 'Loading state from', self.db_name, 'database'
  
          # If we are not closed, then we need to close first before we
--- 701,706 ----
  
          if options["globals", "verbose"]:
!             print >> sys.stderr, "Loading state from %s (%s) database" % \
!                   (self.db_filename, self.db_name)
  
          # If we are not closed, then we need to close first before we
***************
*** 711,714 ****
--- 713,717 ----
          self.conn = self.db.open()
          root = self.conn.root()
+         
          self.classifier = root.get(self.db_name)
          if self.classifier is None:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.