[Spambayes-checkins] spambayes/spambayes ImapUI.py, 1.19, 1.20 ProxyUI.py, 1.25, 1.26 ServerUI.py, 1.1, 1.2 UserInterface.py, 1.25, 1.26 storage.py, 1.34, 1.35

Tony Meyer anadelonbrin at users.sourceforge.net
Wed Sep 24 01:28:56 EDT 2003


Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv32618/spambayes

Modified Files:
	ImapUI.py ProxyUI.py ServerUI.py UserInterface.py storage.py 
Log Message:
This should fix [ spambayes-Bugs-809769 ] TypeError when training 1.0a6

Index: ImapUI.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/ImapUI.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** ImapUI.py	19 Sep 2003 23:38:10 -0000	1.19
--- ImapUI.py	24 Sep 2003 05:28:53 -0000	1.20
***************
*** 47,52 ****
  from Options import options, optionsPathname
  
- global classifier
- 
  # These are the options that will be offered on the configuration page.
  # If the option is None, then the entry is a header and the following
--- 47,50 ----
***************
*** 110,114 ****
      """Serves the HTML user interface for the proxies."""
      def __init__(self, cls, imap, pwd):
!         global classifier, parm_map
          # Only offer SSL if it is available
          try:
--- 108,112 ----
      """Serves the HTML user interface for the proxies."""
      def __init__(self, cls, imap, pwd):
!         global parm_map
          # Only offer SSL if it is available
          try:
***************
*** 119,123 ****
              parm_map = tuple(parm_list)
          UserInterface.UserInterface.__init__(self, cls, parm_map, adv_map)
!         classifier = cls
          self.imap = imap
          self.imap_pwd = pwd
--- 117,121 ----
              parm_map = tuple(parm_list)
          UserInterface.UserInterface.__init__(self, cls, parm_map, adv_map)
!         self.classifier = cls
          self.imap = imap
          self.imap_pwd = pwd
***************
*** 127,132 ****
      def onHome(self):
          """Serve up the homepage."""
!         stateDict = classifier.__dict__.copy()
!         stateDict.update(classifier.__dict__)
          statusTable = self.html.statusTable.clone()
          del statusTable.proxyDetails
--- 125,130 ----
      def onHome(self):
          """Serve up the homepage."""
!         stateDict = self.classifier.__dict__.copy()
!         stateDict.update(self.classifier.__dict__)
          statusTable = self.html.statusTable.clone()
          del statusTable.proxyDetails
***************
*** 154,159 ****
          restores the defaults."""
          # Reload the options.
!         global classifier
!         classifier.store()
          import Options
          reload(Options)
--- 152,156 ----
          restores the defaults."""
          # Reload the options.
!         self.classifier.store()
          import Options
          reload(Options)

Index: ProxyUI.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/ProxyUI.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** ProxyUI.py	19 Sep 2003 23:47:11 -0000	1.25
--- ProxyUI.py	24 Sep 2003 05:28:53 -0000	1.26
***************
*** 660,664 ****
          # Reload the options.
          global state
-         state.bayes.store()
          import Options
          reload(Options)
--- 660,663 ----
***************
*** 668,671 ****
--- 667,671 ----
          # Recreate the state.
          state = self.state_recreator()
+         self.classifier = state.bayes
  
      def verifyInput(self, parms, pmap):

Index: ServerUI.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/ServerUI.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ServerUI.py	6 Sep 2003 04:03:35 -0000	1.1
--- ServerUI.py	24 Sep 2003 05:28:53 -0000	1.2
***************
*** 101,105 ****
          self.state = self.state_recreator()
  
!     def verifyInput(self, parms):
          '''Check that the given input is valid.'''
          # Most of the work here is done by the parent class, but
--- 101,105 ----
          self.state = self.state_recreator()
  
!     def verifyInput(self, parms, pmap):
          '''Check that the given input is valid.'''
          # Most of the work here is done by the parent class, but

Index: UserInterface.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/UserInterface.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** UserInterface.py	19 Sep 2003 23:38:10 -0000	1.25
--- UserInterface.py	24 Sep 2003 05:28:53 -0000	1.26
***************
*** 86,91 ****
            'message', 'train', 'classify', 'query')
  
- global classifier
- 
  class UserInterfaceServer(Dibbler.HTTPServer):
      """Implements the web server component via a Dibbler plugin."""
--- 86,89 ----
***************
*** 246,252 ****
      def __init__(self, bayes, config_parms=(), adv_parms=()):
          """Load up the necessary resources: ui.html and helmet.gif."""
-         global classifier
          BaseUserInterface.__init__(self)
!         classifier = bayes
          self.parm_ini_map = config_parms
          self.advanced_options_map = adv_parms
--- 244,249 ----
      def __init__(self, bayes, config_parms=(), adv_parms=()):
          """Load up the necessary resources: ui.html and helmet.gif."""
          BaseUserInterface.__init__(self)
!         self.classifier = bayes
          self.parm_ini_map = config_parms
          self.advanced_options_map = adv_parms
***************
*** 274,278 ****
          cluesRow = cluesTable.cluesRow.clone()
          del cluesTable.cluesRow   # Delete dummy row to make way for real ones
!         fetchword = classifier._wordinfoget
          for word, wordProb in clues:
              record = fetchword(word)
--- 271,275 ----
          cluesRow = cluesTable.cluesRow.clone()
          del cluesTable.cluesRow   # Delete dummy row to make way for real ones
!         fetchword = self.classifier._wordinfoget
          for word, wordProb in clues:
              record = fetchword(word)
***************
*** 281,285 ****
                  nspam = record.spamcount
                  if wordProb is None:
!                     wordProb = classifier.probability(record)
              elif word != "*H*" and word != "*S*":
                  nham = nspam = 0
--- 278,282 ----
                  nspam = record.spamcount
                  if wordProb is None:
!                     wordProb = self.classifier.probability(record)
              elif word != "*H*" and word != "*S*":
                  nham = nspam = 0
***************
*** 300,308 ****
              for tok in tokens:
                  clues.append((tok, None))
!             probability = classifier.spamprob(tokens)
              cluesTable = self._fillCluesTable(clues)
              head_name = "Tokens"
          else:
!             (probability, clues) = classifier.spamprob(tokens, evidence=True)
              cluesTable = self._fillCluesTable(clues)
              head_name = "Clues"
--- 297,305 ----
              for tok in tokens:
                  clues.append((tok, None))
!             probability = self.classifier.spamprob(tokens)
              cluesTable = self._fillCluesTable(clues)
              head_name = "Tokens"
          else:
!             (probability, clues) = self.classifier.spamprob(tokens, evidence=True)
              cluesTable = self._fillCluesTable(clues)
              head_name = "Clues"
***************
*** 379,386 ****
              stats.append("You must enter a word.")
          elif query_type == "basic" and not ignore_case:
!             wordinfo = classifier._wordinfoget(word)
              if wordinfo:
                  stat = (word, wordinfo.spamcount, wordinfo.hamcount,
!                         classifier.probability(wordinfo))
              else:
                  stat = "%r does not exist in the database." % \
--- 376,383 ----
              stats.append("You must enter a word.")
          elif query_type == "basic" and not ignore_case:
!             wordinfo = self.classifier._wordinfoget(word)
              if wordinfo:
                  stat = (word, wordinfo.spamcount, wordinfo.hamcount,
!                         self.classifier.probability(wordinfo))
              else:
                  stat = "%r does not exist in the database." % \
***************
*** 400,404 ****
  
              reached_limit = False
!             for w in classifier._wordinfokeys():
                  if not reached_limit and len(stats) >= max_results:
                      reached_limit = True
--- 397,401 ----
  
              reached_limit = False
!             for w in self.classifier._wordinfokeys():
                  if not reached_limit and len(stats) >= max_results:
                      reached_limit = True
***************
*** 408,414 ****
                          over_limit += 1
                      else:
!                         wordinfo = classifier._wordinfoget(w)
                          stat = (w, wordinfo.spamcount, wordinfo.hamcount,
!                                 classifier.probability(wordinfo))
                          stats.append(stat)
              if len(stats) == 0 and max_results > 0:
--- 405,411 ----
                          over_limit += 1
                      else:
!                         wordinfo = self.classifier._wordinfoget(w)
                          stat = (w, wordinfo.spamcount, wordinfo.hamcount,
!                                 self.classifier.probability(wordinfo))
                          stats.append(stat)
              if len(stats) == 0 and max_results > 0:
***************
*** 495,499 ****
          for message in messages:
              tokens = tokenizer.tokenize(message)
!             classifier.learn(tokens, isSpam)
              f.write("From pop3proxy at spambayes.org Sat Jan 31 00:00:00 2000\n")
              f.write(message)
--- 492,496 ----
          for message in messages:
              tokens = tokenizer.tokenize(message)
!             self.classifier.learn(tokens, isSpam)
              f.write("From pop3proxy at spambayes.org Sat Jan 31 00:00:00 2000\n")
              f.write(message)
***************
*** 577,581 ****
          self.write("<b>Saving... ")
          self.flush()
!         classifier.store()
          self.write("Done</b>.\n")
  
--- 574,578 ----
          self.write("<b>Saving... ")
          self.flush()
!         self.classifier.store()
          self.write("Done</b>.\n")
  

Index: storage.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/storage.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** storage.py	18 Sep 2003 14:04:31 -0000	1.34
--- storage.py	24 Sep 2003 05:28:53 -0000	1.35
***************
*** 169,172 ****
--- 169,181 ----
          getattr(self.dbm, "close", noop)()
          # should not be a need to drop the 'dbm' or 'db' attributes.
+         # but we do anyway, because it makes it more clear what has gone
+         # wrong if we try to keep using the database after we have closed
+         # it.
+         if hasattr(self, "db"):
+             del self.db
+         if hasattr(self, "dbm"):
+             del self.dbm
+         if options["globals", "verbose"]:
+             print >> sys.stderr, 'Closed',self.db_name,'database'
  
      def load(self):





More information about the Spambayes-checkins mailing list