Ticket #8979 (new enhancement)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: bof Assigned to: ChrisNelson
Priority: normal Component: TracJsGanttPlugin
Severity: normal Keywords:
Cc: rjollos Trac Release: 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)

Attachments

tracjsganttplugin-macroconfig-c10414.patch (4.6 kB) - added by bof on 07/12/11 21:30:19.
make use of TracMacroConfigPlugin for inheritable macro option defaults
tracjsganttplugin-macroconfig-setup-c10414.patch (0.8 kB) - added by bof on 07/13/11 13:17:42.
additional patch, against setup.py, to automatically install the dependency. thx rjollos for the example.
tracjsganttplugin-macroconfig-c10480.patch (4.2 kB) - added by bof on 07/16/11 21:19:11.
combined and updated patch, includes new goal option
tracjsganttplugin-macroconfig-c10568.patch (16.9 kB) - added by bof on 08/08/11 13:57:45.
refreshed patch, now using TracMacroConfigPlugin descriptor options
tracjsganttplugin-0.9r10710_c10568patched.tar.gz (135.5 kB) - added by kalden on 09/30/11 16:32:11.
http://trac-hacks.org/browser/tracjsganttplugin/0.11?rev=10710 patched from http://trac-hacks.org/attachment/ticket/8979/tracjsganttplugin-macroconfig-c10568.patch

Change History

07/12/11 21:30:19 changed by bof

  • attachment tracjsganttplugin-macroconfig-c10414.patch added.

make use of TracMacroConfigPlugin for inheritable macro option defaults

(in reply to: ↑ description ) 07/13/11 07:02:09 changed by rjollos

Replying to bof:

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.

07/13/11 13:17:42 changed by bof

  • attachment tracjsganttplugin-macroconfig-setup-c10414.patch added.

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

07/16/11 21:19:11 changed by bof

  • attachment tracjsganttplugin-macroconfig-c10480.patch added.

combined and updated patch, includes new goal option

08/08/11 13:57:45 changed by bof

  • attachment tracjsganttplugin-macroconfig-c10568.patch added.

refreshed patch, now using TracMacroConfigPlugin descriptor options

08/08/11 14:01:51 changed by bof

  • cc set to rjollos.

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.

09/30/11 16:32:11 changed by kalden

  • attachment tracjsganttplugin-0.9r10710_c10568patched.tar.gz added.

Add/Change #8979 ([PATCH] macro config=xxx argument, trac.ini option lookup with inheritance)




Change Properties
Action