Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

#8766 closed enhancement (fixed)

Hide configuration options for disabled components

Reported by: Remy Blank Owned by: Remy Blank
Priority: normal Milestone: 0.12
Component: general Version: devel
Severity: normal Keywords: config
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Configuration options (subclasses of Option) are registered in a global registry (Option.registry) so that the default values can be retrieved, and also for the TracIniMacro to display the documentation.

The registry lists options for enabled and disabled components alike. Hence, the TracIniMacro also shows documentation for disabled components. This is undesirable, especially if we have components in tracopt that are disabled by default.

The idea is to modify the TracIniMacro so that it only lists options for enabled components. Moreover, the defaults written to trac.ini on environment creation and trac.ini.sample on upgrade should also only contain options for enabled components.

Attachments (1)

8766-disabled-config-r8684.patch (10.1 KB ) - added by Remy Blank 15 years ago.
Hide config options for disabled components.

Download all attachments as: .zip

Change History (9)

comment:1 by Remy Blank, 15 years ago

Milestone: 0.12

comment:2 by osimons, 15 years ago

Fully agree with fixing both issues as suggested.

by Remy Blank, 15 years ago

Hide config options for disabled components.

comment:3 by Remy Blank, 15 years ago

The patch above hides configuration options for disabled components:

  • in the output of the [[TracIni]] macro
  • in the configuration displayed on /about
  • in trac.ini for a newly-created environment, and in trac.ini.sample for an upgraded environment.

The change was pretty heavy, as configuration objects have no notion of the environment. The basic idea is to add an optional compmgr argument (a ComponentManager, usually the environment object) to all iteration methods, and to filter out options belonging to disabled components if it is specified.

Thoughts?

comment:4 by Christian Boos, 15 years ago

Keywords: config added

This is a good change, except for one thing, not writing the default settings for disabled components in the trac.ini.sample file.

I think we should keep writing the options there, because at upgrade time, we don't know if the user really wants to keep those components disabled or is going to enable them the moment after. If the user does so, then he should be able to benefit from the presence of the related settings in the sample ini file.

Some comments on the patch itself:

In about.py, as you've touched the sort lines, instead of:

sections.sort(lambda x, y: cmp(x['name'], y['name']))

prefer:

sections = sections.sorted(key=lambda s: s['name'])

In config.py, I think get_registry(compmgr=None) should be better called get_enabled_options(compmgr), it's clearer and you can simplify the docstring and remove the test for compmgr. If we need all the options, we can keep using Option.registry.

comment:5 by Remy Blank, 15 years ago

Thanks for your comments!

Ok for keeping the options for disabled components in trac.ini.sample.

About the sort lines, I actually only "normalized" some missing whitespace. But you're right, as long as I'm touching the code, I may as well clean it up. I'll have to do something like that, though (I don't think a list has a .sorted() method:

sections = sorted(sections, key=lambda s: s['name'])

About get_registry(), I would rather keep it as-is, as it's called from two locations with an argument where we don't know a-priori if it's None or not. If I removed the argument, I would have to add the check in those two locations, and decide between calling get_enabled_options() or getting Option.registry.

But maybe get_options() would be a better name?

in reply to:  5 ; comment:6 by Christian Boos, 15 years ago

Replying to rblank:

Thanks for your comments!

Ok for keeping the options for disabled components in trac.ini.sample.

Perfect.

I'll have to do something like that, though (I don't think a list has a .sorted() method:

Sorry, I was in mixed Ruby/Python mode ;-)

About get_registry(), I would rather keep it as-is, as it's called from two locations with an argument where we don't know a-priori if it's None or not. If I removed the argument, I would have to add the check in those two locations, and decide between calling get_enabled_options() or getting Option.registry.

Ok, it's not as clear cut as I thought, so we can as well keep get_registry().

in reply to:  6 comment:7 by Remy Blank, 15 years ago

Replying to cboos:

Sorry, I was in mixed Ruby/Python mode ;-)

What!?! Traitor! :-)

(I'll have to try Ruby some day, looks pretty interesting.)

comment:8 by Remy Blank, 15 years ago

Resolution: fixed
Status: newclosed

Updated patch applied in [8686].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank 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.