#9544 closed enhancement (wontfix)
Provide enum options for usage in plugins
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | general | Version: | |
Severity: | normal | Keywords: | configuration option enum mapping |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
It would be nice to have default implementations for these types of config options.
- One string value in a set (like enums).
- Some string value in a set (like lists of enums).
It'd be nice to have these for usage in plugins ;o)
Attachments (0)
Change History (9)
comment:1 by , 14 years ago
follow-up: 3 comment:2 by , 14 years ago
Milestone: | → unscheduled |
---|
For one string option in a set, see ChoiceOption
. For a subset of strings in a set:
my_option = ListOption('section', 'my_option') allowed_options = set('option1', 'option2', 'option3') def my_fun(self): my_option = set(self.my_option) if my_option - allowed_options: raise ConfigurationError("Invalid option [section] my_option")
Is it really worth adding yet another option type for that?
A MappingOption
sounds useful, though.
follow-up: 4 comment:3 by , 14 years ago
Keywords: | mapping added |
---|
Replying to rblank:
For one string option in a set, see
ChoiceOption
. For a subset of strings in a set
$ grep -r ChoiceOption /usr/lib/python2.5/site-packages/Trac-0.11.7-py2.5.egg/trac
where ? I forgot to mention that I'm using 0.11 .
Is it really worth adding yet another option type for that?
Definitely not. The fact is that I just can't find it …
A
MappingOption
sounds useful, though.
;o)
follow-up: 5 comment:4 by , 14 years ago
Replying to olemis+trac@…:
where ? I forgot to mention that I'm using 0.11 .
I guess it was introduced in 0.12, then. Adding new features in 0.11-stable is a no-go, sorry.
Definitely not. The fact is that I just can't find it …
My example for "a subset of strings in a set" was using ListOption
, and actually, the "one string option in a set" could use ListOption
as well. You should be able to find that one, right? :)
Related to MappingOption
, how about a JSONOption
, taking a JSON string and converting it to a dict
/ list
/ value hierarchy?
comment:5 by , 14 years ago
Replying to rblank:
Replying to olemis+trac@…:
where ? I forgot to mention that I'm using 0.11 .
I guess it was introduced in 0.12, then. Adding new features in 0.11-stable is a no-go, sorry.
Ok , I'll add a compat
module to my plugin ;o)
Definitely not. The fact is that I just can't find it …
My example for "a subset of strings in a set" was using
[…]
Oh ! I think there's a misunderstanding here . I understood your workaround , I couldn't find ConfigOption
. I suppose it's a consequence of my fast and furious relationship with my keyboard :P
Related to
MappingOption
, how about aJSONOption
, taking a JSON string and converting it to adict
/list
/ value hierarchy?
I'd like it , nonetheless I'd also consider these facts
- The syntax I mentioned before is already in use, so changes will be transparent (intuitive ?) for users & Trac admins and useful for core & plugin developers.
- JSON syntax is more complicated yet powerful (pros. and cons.)
- There is a JSON parser in recent versions of stdlib but not in older releases.
So I'd suggest adding two separate implementations , and JSON options only present if JSON support is available once simplejson
is installed or because the package is already in stdlib .
follow-up: 7 comment:6 by , 14 years ago
This ticket risks to stay unscheduled for a long time if there's no more precise requirements (or at least an example of a "mapping").
comment:7 by , 14 years ago
Replying to cboos:
This ticket risks to stay unscheduled for a long time if there's no more precise requirements (or at least an example of a "mapping").
Please take a look at MappingOption
class included in TracMacTheme .
comment:8 by , 9 years ago
Milestone: | unscheduled |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Adding the MappingOption
sound good to me. If you prepare a patch for the trunk along with unit tests I'll review and push the change. For now, closing as wontfix since it's been 5 years.
Another useful kind of configuration options is
ListOption
, that formats option values like a dictionary in a way similar to the default mimetypes map. IOW after splitting values so as to obtain the list, split each item in key, value pairs using another separator (:
by default ?)