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: | 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)
Change History (5)
by , 15 years ago
Attachment: | fix-config-inherit.patch added |
---|
comment:1 by , 15 years ago
comment:3 by , 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 345 345 if value is not _use_default: 346 346 break 347 347 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 350 353 if value is _use_default: 351 354 return default 352 355 if not value:
comment:4 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch applied in [9115], together with a test case.
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).