#5651 closed defect (fixed)
[patch] Use 'inherit' 'file' config setting when creating a new Environment (not loading defaults)
Reported by: | Owned by: | osimons | |
---|---|---|---|
Priority: | normal | Milestone: | 0.11 |
Component: | general | Version: | devel |
Severity: | normal | Keywords: | environment inherit |
Cc: | Christian Boos, shepting@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
As I have started upgrading my code from 0.10 to 0.11 I have found this problem: My automated project creation now gives me new projects with 168 lines of default config options - whereas current setup with 0.10 I have only a few as the rest being inherited from global trac.ini.
The problem is obviously that there is no longer any trac.siteconfig that allows us to fetch a reference to any global trac.ini. The current mechanism is [inherit] file = ...
in project trac.ini.
However, passing options = [('inherit', 'file', '/path/to/global/trac.ini'),]
to Environment('/path/to/project', create=True, options)
does not make a difference - current code loads all defaults, then add the line to the config options as any other setting. For any other setting that is likely an OK approach (as it overwrites defaults), but for file inheritance it is not as any inherited setting will now be overridden by defaults regardless.
Enclosed is a patch that:
- Does not load defaults if options are passed to Environment create, and one of those options is
('inherit', 'file')
. - If inherit-file option, it also fully reloads the config after options have been written to file, as the 'inherit' will then be processed as well.
- Fixes environment created routine in workflow that assumes that settings never exists if it is a new project. The patch for workflow should be applied regardless, as if if an environment is created by passing in a custom workflow as options to create, the workflow routine will actually overwrite parts of that config - whatever lines it can match with own defaults… You get part custom, and part default - nice :-)
Attachments (3)
Change History (17)
by , 17 years ago
Attachment: | env_create_config-011dev-r5789.diff added |
---|
comment:1 by , 17 years ago
Keywords: | inherit added |
---|---|
Milestone: | → 0.11 |
Owner: | changed from | to
Patch looks good. Eli, can you please validate it as well?
comment:2 by , 17 years ago
This would solve the 'back-end' support, but pre-existing ticket #5372 (sorry I missed that earlier) is also a reminder to add a way of specifying the option when using trac-admin initenv
.
follow-up: 4 comment:3 by , 17 years ago
Status: | new → assigned |
---|
I think the change to the workflow code looks ok. The changes to env.py I'm not sure about.
- There are two places where we could be loading the defaults:
Environment.__init__()
and Environment.create(). It looks like in the case we pass the create flag to__init__
, the config (with defaults) will get loaded twice. - I don't see any code to account for recursive use of
[inherit] file =
.
comment:4 by , 17 years ago
Replying to ecarter:
- I don't see any code to account for recursive use of
[inherit] file =
.
Ah, .parent
. Hmm.
by , 17 years ago
Attachment: | env_create_config-011dev-r5829.diff added |
---|
I've added a bit to the doc strings. I also tried using parse_if_needed(). Can you test this patch and let me know if it works for you?
comment:6 by , 17 years ago
Eli, that patch works nicely - env.config.parse_if_needed()
does the trick as well, and it is then the best way.
One tiny addition to docs: ...expected to be provided by that file or other options.
comment:7 by , 17 years ago
Cc: | added |
---|
comment:8 by , 17 years ago
the patch works … could you be so kind to commit it as christian already commented above?
by , 17 years ago
Attachment: | env_create_config-011dev-r6213.diff added |
---|
Updated for rev 6213, and added trac-admin support for initenv with option--inherit=/path/to/global/trac.ini
comment:9 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
Looks very good to me.
Time to apply your own patches, don't you think? :-)
comment:10 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
It is indeed :-)
Last patch applied in [6226]. Closing.
comment:13 by , 17 years ago
I added a note about --inherit
to wiki:0.11/TracIni. It should also be documented in trac-admin
help. If one or the other had existed, I would not have open #7038…
comment:14 by , 17 years ago
Description: | modified (diff) |
---|
Documented in TracIni@126 and TracAdmin@27.
Patch that makes Environment.create(options) behave better if
[inherit] file = ...
if it is passed in as option.