[Spambayes-checkins] spambayes/Outlook2000 addin.py,1.41,1.42

Mark Hammond mhammond at users.sourceforge.net
Sat Dec 14 06:48:43 EST 2002


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

Modified Files:
	addin.py 
Log Message:
Handle failure locating the previously configured folders when starting 
up - particularly when, say, the "Store ID" of the main store changes - 
which it does when you reinstall Outlook (even using the old .pst file)
or even re-configuring Outlook in "Corporate" mode seems to do it.

We disable filtering and display a message box indicating that we should
be reconfigured.

Also make some incremental trace messages (and comments) clearer they are 
doing the right thing!


Index: addin.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/addin.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** addin.py	9 Dec 2002 09:18:38 -0000	1.41
--- addin.py	14 Dec 2002 14:48:40 -0000	1.42
***************
*** 311,315 ****
          for msgstore_message in msgstore_messages:
              # Must train before moving, else we lose the message!
!             print "Training on message - ",
              if train.train_message(msgstore_message, True, self.manager, rescore = True):
                  print "trained as spam"
--- 311,316 ----
          for msgstore_message in msgstore_messages:
              # Must train before moving, else we lose the message!
!             subject = msgstore_message.GetSubject()
!             print "Deleting and spam training message '%s' - " % (subject,),
              if train.train_message(msgstore_message, True, self.manager, rescore = True):
                  print "trained as spam"
***************
*** 318,321 ****
--- 319,324 ----
              # Now move it.
              msgstore_message.MoveTo(spam_folder)
+             # Note the move will possibly also trigger a re-train
+             # but we are smart enough to know we have already done it.
  
  class ButtonRecoverFromSpamEvent(ButtonDeleteAsEventBase):
***************
*** 345,349 ****
          for msgstore_message in msgstore_messages:
              # Must train before moving, else we lose the message!
!             print "Training on message - ",
              if train.train_message(msgstore_message, False, self.manager, rescore = True):
                  print "trained as ham"
--- 348,353 ----
          for msgstore_message in msgstore_messages:
              # Must train before moving, else we lose the message!
!             subject = msgstore_message.GetSubject()
!             print "Recovering and ham training message '%s' - " % (subject,),
              if train.train_message(msgstore_message, False, self.manager, rescore = True):
                  print "trained as ham"
***************
*** 353,356 ****
--- 357,362 ----
              # XXX - still don't write the source, so no point looking :(
              msgstore_message.MoveTo(inbox_folder)
+             # Note the move will possibly also trigger a re-train
+             # but we are smart enough to know we have already done it.
  
  # Helpers to work with images on buttons/toolbars.
***************
*** 572,577 ****
              self.explorers_events._DoNewExplorer(explorer, True)
  
-         self.FiltersChanged()
          if self.manager.config.filter.enabled:
              try:
                  self.ProcessMissedMessages()
--- 578,583 ----
              self.explorers_events._DoNewExplorer(explorer, True)
  
          if self.manager.config.filter.enabled:
+             self.FiltersChanged()
              try:
                  self.ProcessMissedMessages()
***************
*** 600,605 ****
  
      def FiltersChanged(self):
!         # Create a notification hook for all folders we filter.
!         self.UpdateFolderHooks()
  
      def UpdateFolderHooks(self):
--- 606,623 ----
  
      def FiltersChanged(self):
!         try:
!             # Create a notification hook for all folders we filter.
!             self.UpdateFolderHooks()
!         except:
!             import traceback
!             print "Error installing folder hooks."
!             traceback.print_exc()
!             self.manager.config.filter.enabled = False
!             self.manager.SaveConfig()
!             win32ui.MessageBox(
!                 "There was an error initializing the Spam plugin\r\n\r\n"
!                 "Spam filtering has been disabled.  Please re-configure\r\n"
!                 "and re-enable this plugin",
!                 "Anti-Spam plugin")
  
      def UpdateFolderHooks(self):





More information about the Spambayes-checkins mailing list