On Wednesday, June 27, 2018 at 5:50:47 AM UTC-7, Michela Ledwidge wrote: > > Is there a way to reference previously declared trac variables rather than > duplicating config info that might change? > > e.g. > > [trac] >> base_url = <trac URI> >> >> >> [metanav] >> logout.redirect = <reference to trac base_url above> > >
Trac uses Python's ConfigParser, which supports interpolation. See here: https://pymotw.com/2/ConfigParser/#combining-values-with-interpolation For example, the following works: [project] trac_url = https://trac.edgewall.org footer = Visit the Trac open source project at<br /><a href="%(trac_url)s">%(trac_url)s</a> You can put values in the [DEFAULT] section and they will be inherited by every section: [DEFAULT] base_url = http://localhost:8001/proj-1.3 [metanav] logout.redirect = %(base_url)s You'll see when inspecting the configuration on the /about page that "base_url" is defined for every section. Be careful not to unintentionally overwrite a value. You may want to prefix everything in [DEFAULT] with a leading underscore. [DEFAULT] _base_url = http://localhost:8001/proj-1.3 [trac] base_url = %(_base_url)s [metanav] logout.redirect = %(_base_url)s - Ryan -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/trac-users. For more options, visit https://groups.google.com/d/optout.
