Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

#8997 closed defect (fixed)

trac.ini file:inhert config values only correct with first file

Reported by: Shane Caraveo <shanec@…> Owned by: Remy Blank
Priority: normal Milestone: 0.12
Component: general Version: 0.12dev
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I hit a problem where values in the inherited files are only correct for the first file in the list. For the second file, the default value from the option registry gets used

I am using the multiple parent config file feature with something like:

[inherit] file = c.ini, d.ini

In d.ini I have:

[project] footer = my sitewide footer

My ini file sturcture looks like:

a.ini → b.ini → c.ini,d.ini

  • a.ini is the projects ini file, it inherits b.ini
  • b.ini is a generated file, and we occasionally overwrite this on updates.
  • c and d contain data that can get changed (via custom admin panels) and are meant to affect all projects in a multi project system.

The implementation of trac.config.section.get fails to actually use the value from d.ini, because it got the default value from the registry when it looked at c.ini.

I'll attach a patch, it's not the most optimal patch but illustrates a fix.

Attachments (1)

fix-config-inherit.patch (1.2 KB ) - added by Shane Caraveo <shanec@…> 15 years ago.

Download all attachments as: .zip

Change History (5)

by Shane Caraveo <shanec@…>, 15 years ago

Attachment: fix-config-inherit.patch added

comment:1 by Shane Caraveo <shanec@…>, 15 years ago

One issue with the patch, if you have:

[inherit] file = a,b,c

And a value is defined in more than one of the files, the first from the list will be used. What precedence happens in that situation should be documented (admittedly haven't looked to see if it is).

comment:2 by Remy Blank, 15 years ago

Owner: set to Remy Blank

I'll have a look at this.

comment:3 by Remy Blank, 15 years ago

Confirmed, thanks for the bug report. Could you please try this slightly simpler patch?

  • trac/config.py

    diff --git a/trac/config.py b/trac/config.py
    a b  
    345345                if value is not _use_default:
    346346                    break
    347347            else:
    348                 option = Option.registry.get((self.name, key))
    349                 value = option and option.default or _use_default
     348                if default is not _use_default:
     349                    option = Option.registry.get((self.name, key))
     350                    value = option and option.default or _use_default
     351                else:
     352                    value = _use_default
    350353        if value is _use_default:
    351354            return default
    352355        if not value:

comment:4 by Remy Blank, 15 years ago

Resolution: fixed
Status: newclosed

Patch applied in [9115], together with a test case.

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.