[Spambayes-checkins] spambayes/spambayes UserInterface.py, 1.57, 1.58

Tony Meyer anadelonbrin at users.sourceforge.net
Sun May 22 05:32:24 CEST 2005


Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17045/spambayes

Modified Files:
	UserInterface.py 
Log Message:
Fix the handling of the notate_to and notate_subject options.  Previously, although
 these could be set to whatever the header_X_string options were, that could only
 be at runtime, not when loading in the config string - so they would revert whenever
 spambayes was restarted.

Now we special case them all over the damn place (stupid OE).  Here we do the special
 case for offering them in the config page, and checking them in a submitted config
 page.

Index: UserInterface.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/UserInterface.py,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -d -r1.57 -r1.58
*** UserInterface.py	7 Apr 2005 00:25:42 -0000	1.57
--- UserInterface.py	22 May 2005 03:32:19 -0000	1.58
***************
*** 722,727 ****
              html_key = sect + '_' + opt
  
              # Populate the rows with the details and add them to the table.
!             if type(options.valid_input(sect, opt)) in types.StringTypes:
                  # we provide a text input
                  newConfigRow1 = configTextRow1.clone()
--- 722,741 ----
              html_key = sect + '_' + opt
  
+             # Annoyingly, we have a special case.  The notate_to and
+             # notate_subject allowed values have to be set to the same
+             # values as the header_x_ options. See also sf #944109.
+             # This code was originally in Options.py, after loading in the
+             # options.  But that doesn't work, because if we are setting
+             # both in a config file, we need it done immediately.
+             # We now need the hack here, *and* in OptionsClass.py
+             if sect == "Headers" and opt in ("notate_to", "notate_subject"):
+                 valid_input = (options["Headers", "header_ham_string"],
+                                options["Headers", "header_spam_string"],
+                                options["Headers", "header_unsure_string"])
+             else:
+                 valid_input = options.valid_input(sect, opt)
+ 
              # Populate the rows with the details and add them to the table.
!             if isinstance(valid_input, types.StringTypes):
                  # we provide a text input
                  newConfigRow1 = configTextRow1.clone()
***************
*** 736,740 ****
                  firstOpt = True
                  i = 0
!                 for val in options.valid_input(sect, opt):
                      newOption = blankOption.clone()
                      if options.multiple_values_allowed(sect, opt):
--- 750,754 ----
                  firstOpt = True
                  i = 0
!                 for val in valid_input:
                      newOption = blankOption.clone()
                      if options.multiple_values_allowed(sect, opt):
***************
*** 886,889 ****
--- 900,918 ----
                  nice_section_name = sect
                  continue
+ 
+             # Annoyingly, we have a special case.  The notate_to and
+             # notate_subject allowed values have to be set to the same
+             # values as the header_x_ options. See also sf #944109.
+             # This code was originally in Options.py, after loading in the
+             # options.  But that doesn't work, because if we are setting
+             # both in a config file, we need it done immediately.
+             # We now need the hack here, *and* in OptionsClass.py
+             if sect == "Headers" and opt in ("notate_to", "notate_subject"):
+                 valid_input = (options["Headers", "header_ham_string"],
+                                options["Headers", "header_spam_string"],
+                                options["Headers", "header_unsure_string"])
+             else:
+                 valid_input = options.valid_input(sect, opt)
+ 
              html_key = sect + '_' + opt
              if not parms.has_key(html_key):
***************
*** 908,914 ****
                            (entered_value, nice_section_name,
                             options.display_name(sect, opt))
!                 if type(options.valid_input(sect, opt)) == type((0,1)):
                      errmsg += _('. Valid values are: ')
!                     for valid in options.valid_input(sect, opt):
                          errmsg += str(valid) + ','
                      errmsg = errmsg[:-1] # cut last ','
--- 937,943 ----
                            (entered_value, nice_section_name,
                             options.display_name(sect, opt))
!                 if isinstance(valid_input, types.TupleType):
                      errmsg += _('. Valid values are: ')
!                     for valid in valid_input:
                          errmsg += str(valid) + ','
                      errmsg = errmsg[:-1] # cut last ','



More information about the Spambayes-checkins mailing list