Opened 5 years ago

# [PATCH] macro config=xxx argument, trac.ini option lookup with inheritance

Reported by: Owned by: bof ChrisNelson normal TracJsGanttPlugin normal rjollos 0.11

### Description

As discussed shortly in #8704, here is a patch providing inheritable option lookup and defaulting.

NOTE: depends on the newly created TracMacroConfigPlugin. I'm unsure whether that dependency can somehow be handled automatically in setup.py - there seem to be some options related to that, but I have not yet played with them.

With this patch applied, the configuration can contain something like this:

[trac-jsgantt]
option.inherit = base
base.userMap = 0
base.omitMilestones = 1
base.dateDisplay = yyyy-mm-dd
mini.inherit = base
mini.startDate = 0
mini.endDate = 0
mini.res = 0
mini.dur = 0
mini.comp = 0
mini.lwidth = 256


A macro call with only TracQuery arguments, or other but not all macro arguments, will then take its full option list from the option.xxx option set, which immediately inherits them all from base.xxx for the sake of exposition.

Additionally, a macro call written as [[TracJSGanttChart(config=mini)]], will take its options from the mini.xxx settings (which also inherit some from base.xxx)

It is even possible to write something like [[TracJSGanttChart(config=mini|foobar)]] to get multiple inheritance from mini.xxx, and from foobar.xxx when missing from the mini. path. Such multiple inheritance is also supported within trac.ini for the xxx.inherit = a|b options.

(tested under 0.11.7 and 0.12.2)

### Changed 5 years ago by bof

make use of TracMacroConfigPlugin for inheritable macro option defaults

### comment:1 in reply to: ↑ description Changed 5 years ago by rjollos

NOTE: depends on the newly created TracMacroConfigPlugin. I'm unsure whether that dependency can somehow be handled automatically in setup.py - there seem to be some options related to that, but I have not yet played with them.

The TracHoursPlugin handles the dependencies automatically. You might take a look at its setup.py. Another option is to add a simple install_requires to setup.py.

### Changed 5 years ago by bof

additional patch, against setup.py, to automatically install the dependency. thx rjollos for the example.

### Changed 5 years ago by bof

combined and updated patch, includes new goal option

### Changed 5 years ago by bof

refreshed patch, now using TracMacroConfigPlugin descriptor options

### comment:2 Changed 5 years ago by bof

• Cc rjollos added; anonymous removed

The refreshed patch (c10568), part from modifying how the macro options are looked up, contains one functional enhancement:

Both the root= and goal= options can now contain self among a list of IDs, e.g. "root=1234|self|5435". While cleaning this up, I took the liberty to factor the duplicated code handling root and gool, into a new local function _addin.