Esempio n. 1
0
 def _buildFolderBox(self, section, option, available_folders):

        folderTable = self.html.configTable.clone()

        del folderTable.configTextRow1

        del folderTable.configTextRow2

        del folderTable.configCbRow1

        del folderTable.configRow2

        del folderTable.blankRow

        del folderTable.folderRow

        firstRow = True

        for folder in available_folders:

            folder = cgi.escape(folder)

            folderRow = self.html.configTable.folderRow.clone()

            if firstRow:

                folderRow.helpCell = options.doc(section, option)

                firstRow = False

            else:

                del folderRow.helpCell

            folderRow.folderBox.name = option

            folderRow.folderBox.value = folder

            folderRow.folderName = folder

            if options.multiple_values_allowed(section, option):

                if folder in options[section, option]:

                    folderRow.folderBox.checked = "checked"

                folderRow.folderBox.name += folder

            else:

                if folder == options[section, option]:

                    folderRow.folderBox.checked = "checked"

                folderRow.folderBox.type = "radio"

            folderTable += folderRow

        return self._buildBox(options.display_name(section, option),
                              None, folderTable)
Esempio n. 2
0
 def _buildFolderBox(self, section, option, available_folders):
     folderTable = self.html.configTable.clone()
     del folderTable.configTextRow1
     del folderTable.configTextRow2
     del folderTable.configCbRow1
     del folderTable.configRow2
     del folderTable.blankRow
     del folderTable.folderRow
     firstRow = True
     for folder in available_folders:
         folder = cgi.escape(folder)
         folderRow = self.html.configTable.folderRow.clone()
         if firstRow:
             folderRow.helpCell = options.doc(section, option)
             firstRow = False
         else:
             del folderRow.helpCell
         folderRow.folderBox.name = option
         folderRow.folderBox.value = folder
         folderRow.folderName = folder
         if options.multiple_values_allowed(section, option):
             if folder in options[section, option]:
                 folderRow.folderBox.checked = "checked"
             folderRow.folderBox.name += folder
         else:
             if folder == options[section, option]:
                 folderRow.folderBox.checked = "checked"
             folderRow.folderBox.type = "radio"
         folderTable += folderRow
     return self._buildBox(options.display_name(section, option),
                           None, folderTable)
Esempio n. 3
0
 def verifyInput(self, parms, pmap):
     """Check that the given input is valid."""
     errmsg = ""
     for name, value in parms.items():
         if name[-2:-1] == "-":
             if parms.has_key(name[:-2]):
                 parms[name[:-2]] += (value,)
             else:
                 parms[name[:-2]] = (value,)
             del parms[name]
     for sect, opt in pmap:
         if opt is None:
             nice_section_name = sect
             continue
         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):
             value = ()
             entered_value = "None"
         else:
             value = parms[html_key]
             entered_value = value
             if options.is_boolean(sect, opt):
                 if value == _("No"):
                     value = False
                 elif value == _("Yes"):
                     value = True
             if options.multiple_values_allowed(sect, opt) and value == "":
                 value = ()
             value = options.convert(sect, opt, value)
         if not options.is_valid(sect, opt, value):
             errmsg += _("<li>'%s' is not a value valid for [%s] %s") % (
                 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 ','
             errmsg += "</li>"
         parms[html_key] = value
     return errmsg
Esempio n. 4
0
 def _buildConfigPageBody(self, html, parm_map):
     configTable = None
     section = None
     for sect, opt in parm_map:
         if opt is None:
             if configTable is not None and section is not None:
                 section.boxContent = configTable
                 html.configFormContent += section
             section = self.html.headedBox.clone()
             configTable = self.html.configTable.clone()
             configTextRow1 = configTable.configTextRow1.clone()
             configTextRow2 = configTable.configTextRow2.clone()
             configCbRow1 = configTable.configCbRow1.clone()
             configRow2 = configTable.configRow2.clone()
             blankRow = configTable.blankRow.clone()
             del configTable.configTextRow1
             del configTable.configTextRow2
             del configTable.configCbRow1
             del configTable.configRow2
             del configTable.blankRow
             del configTable.folderRow
             section.heading = sect
             del section.iconCell
             continue
         html_key = sect + "_" + opt
         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)
         if isinstance(valid_input, types.StringTypes):
             newConfigRow1 = configTextRow1.clone()
             newConfigRow1.label = options.display_name(sect, opt)
             newConfigRow1.input.name = html_key
             newConfigRow1.input.value = options.unconvert(sect, opt)
         else:
             newConfigRow1 = configCbRow1.clone()
             newConfigRow1.label = options.display_name(sect, opt)
             blankOption = newConfigRow1.input.clone()
             firstOpt = True
             i = 0
             for val in valid_input:
                 newOption = blankOption.clone()
                 if options.multiple_values_allowed(sect, opt):
                     if val in options[sect, opt]:
                         newOption.input_box.checked = "checked"
                     newOption.input_box.type = "checkbox"
                     newOption.input_box.name = html_key + "-" + str(i)
                     i += 1
                 else:
                     if val == options[sect, opt]:
                         newOption.input_box.checked = "checked"
                     newOption.input_box.type = "radio"
                     newOption.input_box.name = html_key
                 if options.is_boolean(sect, opt):
                     if val is True:
                         val = "Yes"
                     elif val is False:
                         val = "No"
                 newOption.val_label = str(val)
                 newOption.input_box.value = str(val)
                 if firstOpt:
                     newConfigRow1.input = newOption
                     firstOpt = False
                 else:
                     newConfigRow1.input += newOption
         newConfigRow1.helpCell = (
             "<strong>" + options.display_name(sect, opt) + ":</strong> " + cgi.escape(options.doc(sect, opt))
         )
         newConfigRow2 = configRow2.clone()
         currentValue = options[sect, opt]
         if type(currentValue) in types.StringTypes:
             currentValue = currentValue.replace(",", ", ")
             newConfigRow2 = configTextRow2.clone()
         else:
             currentValue = options.unconvert(sect, opt)
             newConfigRow2 = configRow2.clone()
         if options.is_boolean(sect, opt):
             if currentValue == "False":
                 currentValue = _("No")
             elif currentValue == "True":
                 currentValue = _("Yes")
         newConfigRow2.currentValue = currentValue
         configTable += newConfigRow1 + newConfigRow2 + blankRow
     if section is not None:
         section.boxContent = configTable
         html.configFormContent += section
     return html