Modify

Opened 13 years ago

Last modified 5 years ago

#8979 new enhancement

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

Reported by: Patrick Schaaf Owned by: Chris Nelson
Priority: normal Component: TracJsGanttPlugin
Severity: normal Keywords:
Cc: 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 (5)

tracjsganttplugin-macroconfig-c10414.patch (4.6 KB) - added by Patrick Schaaf 13 years ago.
make use of TracMacroConfigPlugin for inheritable macro option defaults
tracjsganttplugin-macroconfig-setup-c10414.patch (808 bytes) - added by Patrick Schaaf 13 years ago.
additional patch, against setup.py, to automatically install the dependency. thx rjollos for the example.
tracjsganttplugin-macroconfig-c10480.patch (4.2 KB) - added by Patrick Schaaf 13 years ago.
combined and updated patch, includes new goal option
tracjsganttplugin-macroconfig-c10568.patch (16.9 KB) - added by Patrick Schaaf 13 years ago.
refreshed patch, now using TracMacroConfigPlugin descriptor options
tracjsganttplugin-0.9r10710_c10568patched.tar.gz (135.5 KB) - added by kalden 13 years ago.
http://trac-hacks.org/browser/tracjsganttplugin/0.11?rev=10710 patched from http://trac-hacks.org/attachment/ticket/8979/tracjsganttplugin-macroconfig-c10568.patch

Download all attachments as: .zip

Change History (8)

Changed 13 years ago by Patrick Schaaf

make use of TracMacroConfigPlugin for inheritable macro option defaults

comment:1 in reply to:  description Changed 13 years ago by Ryan J Ollos

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.

Changed 13 years ago by Patrick Schaaf

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

Changed 13 years ago by Patrick Schaaf

combined and updated patch, includes new goal option

Changed 13 years ago by Patrick Schaaf

refreshed patch, now using TracMacroConfigPlugin descriptor options

comment:2 Changed 13 years ago by Patrick Schaaf

Cc: Ryan J Ollos 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.

comment:3 Changed 5 years ago by Ryan J Ollos

Cc: Ryan J Ollos removed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Chris Nelson.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.