Edgewall Software
Modify

Opened 11 years ago

Last modified 3 years ago

#7573 new enhancement

base_url for many projects is painful

Reported by: doki_pen <doki_pen@…> Owned by:
Priority: normal Milestone: next-major-releases
Component: general Version: 0.12dev
Severity: normal Keywords: base_url patch
Cc: boftx@…, shtrom-trac@…, Ryan J Ollos Branch:
Release Notes:
API Changes:

Description

Setting the base_url in hundreds of ini files, and changing them with a hostname change is painful. I've attached a patch for a parent_base_url trac.ini setting that can be used in a parent trac.ini.

Attachments (1)

parent_base_url-r7499.diff (1.7 KB ) - added by doki_pen <doki_pen@…> 11 years ago.
Add a parent_base_url setting.

Download all attachments as: .zip

Change History (22)

by doki_pen <doki_pen@…>, 11 years ago

Attachment: parent_base_url-r7499.diff added

Add a parent_base_url setting.

comment:1 by osimons, 11 years ago

Owner: set to osimons

It would be useful, and it was also briefly raised by me on #5064 a while back.

As I see it, there are two alternatives:

  1. Like your patch introduce a new setting for 'parent'.
  2. Or, introduce substitusion in the original base_url so that you can write base_url = http://myhost/trac/$folder for instance.

Regardless, many places in Trac and not least external plugins and scripts make reference to the base_url setting, so I expect a fair amount of breakage for any change in setting or calculation (like the story with #5064). I need other devs to chime in with their opinion before anything gets committed.

comment:2 by doki_pen <doki_pen@…>, 11 years ago

I originally tried using the interpolation feature in ConfigParser to do something like this

# parent.trac.ini
[trac]
parent_base_url = http://myhost/trac
# trac.ini
[inherit]
file = parent.trac.ini

[trac]
base_url = %(parent_base_url)/myproject

But discovered that it doesn't work. The inheritance feature is implemented at a higher level then the interpolation feature. Perhaps this should work and the is what should be changed, but it seemed more difficult.

comment:3 by dave@…, 11 years ago

Mightn't it be easier as environ?

comment:4 by osimons, 11 years ago

#8288 has been closed as a duplicate - it also requests some form of substitution mechanism when parsing trac.ini.

I'm quite partial to a flexible system, and the idea proposed by ebray on that ticket of using ${section:option} replacement makes sense. That way an inherited trac.ini file can reuse or define whatever option it needs to be reused by children.

In addition, this mechanism could support a special ${environ:variable} lookup that reads environment settings instead of looking up configuration files.

We'll skip substitution on a substitution to avoid initiate loops, but otherwise this would be a simple and easy scheme to implement.

comment:5 by boftx@…, 11 years ago

I just closed #8521 as a duplicate of this ticket. I agree with the approach taken by the patch above becuase I think there should be no need for editing the individual trac.ini files in each project. If I understand how the patch works, all I would need is a single entry for "parent_base_url" in the inherited trac.ini file and no further changes would be needed as "base_url" by default is empty.

I originally entered this as a request due to problems encountered with TicketMover. (see http://trac-hacks.org/ticket/5560 for that discussion)

Is there any reason why this patch would not work on 11.4?

comment:6 by boftx@…, 11 years ago

Cc: boftx@… added

comment:7 by Remy Blank, 10 years ago

Simon, what's the currently-favored solution for this issue? Should we keep it for 0.12?

comment:8 by Christian Boos, 10 years ago

The patch looks good.

It's an .ini setting that you have to enable explicitly after all, so we could flag it (experimental) and let the users validate it. If we get negative feedback, we could still fix it later… So +1 from me.

comment:9 by Remy Blank, 10 years ago

Owner: changed from osimons to Remy Blank

Simon, I'll take care of this, if you don't mind.

comment:10 by Remy Blank, 10 years ago

Unfortunately, the patch is incomplete. It correctly sets env.abs_href, but web/main.py accesses env.base_path directly, to set environ['trac.base_path'], which is then used to construct req.abs_href.

One possibility would be to make env.base_path a property, and to rename the Option to e.g. base_path_opt. Thoughts?

comment:11 by Remy Blank, 10 years ago

Milestone: 0.12next-minor-0.12.x

Moving this out of 0.12 until the issues in comment:10 are addressed.

comment:12 by Christian Boos, 10 years ago

Keywords: base_url added
Milestone: next-minor-0.12.xnext-major-0.1X

[OT] would be useful to highlight the heading corresponding to the selected comment link. Here, if I click on comment:10, the comment:7 would be shown at the top of the page, for page height reason. While entirely logical, it was somewhat confusing and a dynamic highlight would have helped (same story for the wiki page section headings, btw).

comment:13 by Ryan J Ollos <ryano@…>, 10 years ago

Cc: ryano@… added

comment:14 by Olivier Mehani <shtrom-trac@…>, 9 years ago

Cc: shtrom-trac@… added

comment:15 by osimons, 9 years ago

#9586 closed as duplicate.

comment:16 by anonymous, 9 years ago

I really like the ${section:option} version. It would make my life a lot easier. I can use that for the password_file and logo_file options.

I'm creating a tool to automate the deployment of tracs, and adding a small section with my tools name and some variables I can use in the rest of the config file would be awesome.

comment:17 by Remy Blank, 8 years ago

Owner: Remy Blank removed

Refocusing.

comment:18 by anonymous, 6 years ago

Hi, how is the status of this ticket?

comment:20 by Ryan J Ollos, 5 years ago

Cc: Ryan J Ollos added; ryano@… removed

comment:21 by strk@…, 4 years ago

I'm also looking for ways to reduce pain of setting base_url for multiple instances. Was an alternative found for Trac 1.0+ ?

comment:22 by figaro, 3 years ago

Keywords: patch added

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned. Next status will be 'new'.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.