Edgewall Software

Changes between Initial Version and Version 1 of Ticket #12779


Ignore:
Timestamp:
Apr 19, 2017, 6:31:47 PM (3 years ago)
Author:
Ryan J Ollos
Comment:

Regression from #11573. We could add a case_sensitive argument to ChoiceOption.

  • trac/config.py

    diff --git a/trac/config.py b/trac/config.py
    index cd43e8887..b8ad92e0e 100644
    a b class ChoiceOption(Option):  
    819819    """
    820820
    821821    def __init__(self, section, name, choices, doc='', doc_domain='tracini',
    822                  doc_args=None):
     822                 doc_args=None, case_sensitive=True):
    823823        Option.__init__(self, section, name, to_unicode(choices[0]), doc,
    824824                        doc_domain, doc_args)
    825825        self.choices = set(to_unicode(c).strip() for c in choices)
     826        self.case_sensitive = case_sensitive
    826827
    827828    def accessor(self, section, name, default):
    828829        value = section.get(name, default)
    829         if value not in self.choices:
     830        choices = self.choices
     831        if not self.case_sensitive:
     832            value = value.lower()
     833            choices = map(unicode.lower, choices)
     834        if value not in choices:
    830835            raise ConfigurationError(
    831836                    _('[%(section)s] %(entry)s: expected one of '
    832837                      '(%(choices)s), got %(value)s',
  • trac/env.py

    diff --git a/trac/env.py b/trac/env.py
    index 0ecbb5b42..19c2b5f3d 100644
    a b class Environment(Component, ComponentManager):  
    250250        """Level of verbosity in log.
    251251
    252252        Should be one of (`CRITICAL`, `ERROR`, `WARNING`, `INFO`, `DEBUG`).
    253         """)
     253        """, case_sensitive=False)
    254254
    255255    log_format = Option('logging', 'log_format', None,
    256256        """Custom logging format.

I would prefer to not make case_sensitive be the last argument in the list, but I suppose that is required for backward-compatibility.

Legend:

Unmodified
Added
Removed
Modified