Edgewall Software
Modify

Opened 14 years ago

Closed 9 years ago

Last modified 9 years ago

#9544 closed enhancement (wontfix)

Provide enum options for usage in plugins

Reported by: olemis+trac@… 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 olemis+trac@…, 14 years ago

Another useful kind of configuration options is

  • Configuration mappings, i.e. a subclass of 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 ?)

comment:2 by Remy Blank, 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.

in reply to:  2 ; comment:3 by olemis+trac@…, 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)

in reply to:  3 ; comment:4 by Remy Blank, 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?

in reply to:  4 comment:5 by olemis+trac@…, 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 a JSONOption, taking a JSON string and converting it to a dict / 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 .

comment:6 by Christian Boos, 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").

in reply to:  6 comment:7 by olemis+trac@…, 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 Ryan J Ollos, 9 years ago

Milestone: unscheduled
Resolution: wontfix
Status: newclosed

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.

comment:9 by olemis, 9 years ago

fair enough .

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.