[Spambayes-checkins] spambayes/Outlook2000 filter.py,1.36,1.37

Mark Hammond mhammond at users.sourceforge.net
Fri Dec 19 01:27:32 EST 2003


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

Modified Files:
	filter.py 
Log Message:
Handle E_OBJECT_CHANGED exception when filtering a message.  This should
fix bug [ 803798 ] MAPI_E_OBJECT_CHANGED error saving spam score, which is
a dupe of [787676], which was incorrectly marked as fixed (as the fix did
not work)

Don't record in the training database unless we are successful in the
filter - otherwise future attempts to filter will get all screwed up,
as it will think it already was.


Index: filter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/filter.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** filter.py	27 Oct 2003 03:34:59 -0000	1.36
--- filter.py	19 Dec 2003 06:27:29 -0000	1.37
***************
*** 13,17 ****
      config = mgr.config.filter
      prob = mgr.score(msg)
-     mgr.stats.RecordClassification(prob)
      prob_perc = prob * 100
      if prob_perc >= config.spam_threshold:
--- 13,16 ----
***************
*** 28,43 ****
      try:
          try:
              if config.save_spam_info:
!                 # Save the score
!                 # Catch this exception, as failing to save the score need not
!                 # be fatal - it may still be possible to perform the move.
!                 msg.SetField(mgr.config.general.field_score_name, prob)
!                 # and the ID of the folder we were in when scored.
!                 # (but only if we want to perform all actions)
!                 # Note we must do this, and the Save, before the
!                 # filter, else the save will fail.
!                 if all_actions:
!                     msg.RememberMessageCurrentFolder()
!                 msg.Save()
          except ms.ReadOnlyException:
              # read-only message - not much we can do!
--- 27,63 ----
      try:
          try:
+             # Save the score
+             # Catch msgstore exceptions, as failing to save the score need
+             # not be fatal - it may still be possible to perform the move.
              if config.save_spam_info:
!                 # The object can sometimes change underneath us (most
!                 # noticably Hotmail, but reported in other cases too).
!                 # Retry 3 times handling ObjectChanged exception.
!                 # Why 3?  Why not!
!                 for i in range(3):
!                     try:
!                         msg.SetField(mgr.config.general.field_score_name, prob)
!                         # and the ID of the folder we were in when scored.
!                         # (but only if we want to perform all actions)
!                         # Note we must do this, and the Save, before the
!                         # filter, else the save will fail.
!                         if all_actions:
!                             msg.RememberMessageCurrentFolder()
!                         msg.Save()
!                         break
!                     except ms.ObjectChangedException:
!                         # Someone has changed the message underneath us.
!                         # The general solution is to re-open the message, and
!                         # try again.  We reach into our knowledge of the
!                         # message to force this.
!                         mgr.LogDebug(1, "Got ObjectChanged changed - " \
!                                         "trying again...")
!                         msg.dirty = False
!                         msg.mapi_object = None # cause it to be re-fetched.
!                 else:
!                     # Give up trying to save the score.
!                     mgr.LogDebug(0, "Got ObjectChanged 3 times in a row - " \
!                                     "giving up!")
!                     msg.dirty = False
          except ms.ReadOnlyException:
              # read-only message - not much we can do!
***************
*** 83,86 ****
--- 103,107 ----
                  raise RuntimeError, "Eeek - bad action '%r'" % (action,)
  
+         mgr.stats.RecordClassification(prob)
          return disposition
      except:





More information about the Spambayes-checkins mailing list