spambayes/spambayes UserInterface.py, 1.56, 1.57

"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-serv10023/spambayes

Modified Files:
	UserInterface.py 
Log Message:
Fix the uploading of messages to train via the web interface, which was broken.

Index: UserInterface.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/UserInterface.py,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** UserInterface.py	6 Apr 2005 02:39:53 -0000	1.56
--- UserInterface.py	7 Apr 2005 00:25:42 -0000	1.57
***************
*** 521,524 ****
--- 521,525 ----
                  corpus = getattr(self.state, desired_corpus)
                  setattr(self, desired_corpus, corpus)
+                 self.msg_name_func = self.state.getNewMessageName
              else:
                  # sb_imapfilter (need to create)
***************
*** 538,541 ****
--- 539,551 ----
                                            '[0123456789\-]*', cacheSize=20)
                  setattr(self, desired_corpus, corpus)
+                 # We need a function to create a new name for the message
+                 # as sb_imapfilter doesn't have one.
+                 class UniqueNamer(object):
+                     count = -1
+                     def generate_name(self):
+                         self.count += 1
+                         return "%10.10d-%d" % (long(time.time()), self.count)
+                 Namer = UniqueNamer()
+                 self.msg_name_func = Namer.generate_name
  
          # Train on the uploaded message(s).
***************
*** 543,547 ****
          self.flush()
          for message in messages:
!             msg = factory.create(key, message)
              corpus.addMessage(msg)
              msg.RememberTrained(isSpam)
--- 553,559 ----
          self.flush()
          for message in messages:
!             key = self.msg_name_func()
!             msg = corpus.makeMessage(key, message)
!             msg.setId(key)
              corpus.addMessage(msg)
              msg.RememberTrained(isSpam)
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.