Edgewall Software
Modify

Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#5651 closed defect (fixed)

[patch] Use 'inherit' 'file' config setting when creating a new Environment (not loading defaults)

Reported by: osimons <simon-code@…> 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 Christian Boos)

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)

env_create_config-011dev-r5789.diff (1.8 KB ) - added by osimons <simon-code@…> 17 years ago.
Patch that makes Environment.create(options) behave better if [inherit] file = ... if it is passed in as option.
env_create_config-011dev-r5829.diff (2.5 KB ) - added by Eli Carter 17 years ago.
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?
env_create_config-011dev-r6213.diff (3.4 KB ) - added by osimons <simon-code@…> 16 years ago.
Updated for rev 6213, and added trac-admin support for initenv with option--inherit=/path/to/global/trac.ini

Download all attachments as: .zip

Change History (17)

by osimons <simon-code@…>, 17 years ago

Patch that makes Environment.create(options) behave better if [inherit] file = ... if it is passed in as option.

comment:1 by Christian Boos, 17 years ago

Keywords: inherit added
Milestone: 0.11
Owner: changed from Jonas Borgström to Eli Carter

Patch looks good. Eli, can you please validate it as well?

comment:2 by osimons <simon-code@…>, 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.

comment:3 by Eli Carter, 17 years ago

Status: newassigned

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 =.

in reply to:  3 comment:4 by Eli Carter, 17 years ago

Replying to ecarter:

  • I don't see any code to account for recursive use of [inherit] file =.

Ah, .parent. Hmm.

by Eli Carter, 17 years ago

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:5 by Eli Carter, 17 years ago

Cc: Christian Boos added

Christian, can you comment on the updated patch?

comment:6 by osimons <simon-code@…>, 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 anonymous, 17 years ago

Cc: shepting@… added

comment:8 by ThurnerRupert, 17 years ago

the patch works … could you be so kind to commit it as christian already commented above?

by osimons <simon-code@…>, 16 years ago

Updated for rev 6213, and added trac-admin support for initenv with option--inherit=/path/to/global/trac.ini

comment:9 by Christian Boos, 16 years ago

Owner: changed from Eli Carter to osimons
Status: assignednew

Looks very good to me.

Time to apply your own patches, don't you think? :-)

comment:10 by osimons, 16 years ago

Resolution: fixed
Status: newclosed

It is indeed :-)

Last patch applied in [6226]. Closing.

comment:11 by osimons, 16 years ago

#6097 closed as duplicate.

comment:12 by osimons, 16 years ago

#7038 closed as duplicate.

comment:13 by jouvin@…, 16 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 Christian Boos, 16 years ago

Description: modified (diff)

Documented in TracIni@126 and TracAdmin@27.

Modify Ticket

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