comparison roundup/configuration.py @ 6358:42db48c30d31

Validate indexer values Make sure that indexer values are one of the supported indexers. Invalid values would have raised an invalid indexer exception on access.
author John Rouillard <rouilj@ieee.org>
date Tue, 30 Mar 2021 02:24:22 -0400
parents c26b9ce33ae3
children 08e209a7f22b
comparison
equal deleted inserted replaced
6357:c985ed52ca2d 6358:42db48c30d31
406 _val = value.lower() 406 _val = value.lower()
407 if _val in self.allowed: 407 if _val in self.allowed:
408 return _val 408 return _val
409 raise OptionValueError(self, value, self.class_description) 409 raise OptionValueError(self, value, self.class_description)
410 410
411 class IndexerOption(Option):
412 """Valid options for indexer"""
413
414 allowed = ['', 'xapian', 'whoosh', 'native']
415 class_description = "Allowed values: %s" % ', '.join("'%s'" % a
416 for a in allowed)
417
418 def str2value(self, value):
419 _val = value.lower()
420 if _val in self.allowed:
421 return _val
422 raise OptionValueError(self, value, self.class_description)
411 423
412 class MailAddressOption(Option): 424 class MailAddressOption(Option):
413 425
414 """Email address 426 """Email address
415 427
740 (BooleanOption, "instant_registration", "no", 752 (BooleanOption, "instant_registration", "no",
741 "Register new users instantly, or require confirmation via\n" 753 "Register new users instantly, or require confirmation via\n"
742 "email?"), 754 "email?"),
743 (BooleanOption, "email_registration_confirmation", "yes", 755 (BooleanOption, "email_registration_confirmation", "yes",
744 "Offer registration confirmation by email or only through the web?"), 756 "Offer registration confirmation by email or only through the web?"),
745 (Option, "indexer", "", 757 (IndexerOption, "indexer", "",
746 "Force Roundup to use a particular text indexer.\n" 758 "Force Roundup to use a particular text indexer.\n"
747 "If no indexer is supplied, the first available indexer\n" 759 "If no indexer is supplied, the first available indexer\n"
748 "will be used in the following order:\n" 760 "will be used in the following order:\n"
749 "Possible values: xapian, whoosh, native (internal)."), 761 "Possible values: xapian, whoosh, native (internal)."),
750 (Option, "indexer_language", "english", 762 (Option, "indexer_language", "english",

Roundup Issue Tracker: http://roundup-tracker.org/