Feature Proposal: Retrieve preference values in different contexts

Motivation

It is often necessary to get preference values in different contexts (at the web level for access controls, for example). The EXPAND macro supports this, but is very clumsy at handling defaults.

Description and Documentation

It would be a simple change to add a scope parameter to the standard preference parameter support, thus:

Definition scope

  • Parameter macros can accept a scope parameter that defines a Web.Topic name so that you can find out the value a preference has in a different scope.
Example: EXAMPLESETTING is defined in System.DefaultPreferences. It is also defined in the WebPreferences for this web, and in this topic.
  • %EXAMPLESETTING% expands to %EXAMPLESETTING% (the preference in this topic)
  • %EXAMPLESETTING{scope="Development."}% expands to %EXAMPLESETTING{scope="Development."}% (the preference elsewhere in this web)
  • %EXAMPLESETTING{scope="."}% expands to %EXAMPLESETTING{scope="."}% (the preference in the default %USERSWEB% web)

Implementation

The code can mostly be cribbed from EXPAND. The attached patch is a complete implementation, including documentation, but without tests.

-- Contributors: CrawfordCurrie - 12 Apr 2012

Discussion

oddities:
  • this overlaps with the parametarised vars - if someone uses %scope% in their setting.
  • web. and . isn't an existing location - I can't say that it looks readable -
  • I certainly don't like '.' means %USERSWEB% - but I Think you mean '.' is the sitewide global context from SITEPREFERENCES

more:
  1. what about the default in the spec file
    • ? This is a config var, not a preference. We don't have any way to map a config var to a preference - at the moment, QUERY is the only way to do that.
    • I'm talking about the defaults in spec files (not what was finally chosen in the LocalSite.cfg) for config vars that initialize preferences - its not the admin/users fault that we've arbitrarily separated these preferences into unrelated things ()
  2. what about the non-topic cfg scope
    • ? What is this?
    • this would be the value as set in LocalSite.cfg - as opposed to the spec file above
  3. what about the DefaultPref scope
    • ? I usually refer to this as the "root scope". Some discussion below.
    • no, its not - root scope it the one at the SitePreferences scope - I mean the values in the scope before SitePrefs is read (ie, cfg file loaded, DefaultPrefs topic loaded)

the functionality is darned useful to the topic based settings wizard, I just don't like the spelling of the special values, and think we need a few more specials

-- SvenDowideit - 18 Apr 2012

Actually the . and Web. and %USERSWEB% came about as a result of experimenting with the existing implementation of EXPAND - which uses normalizeWebTopicName - so they are already an (undocumented, de facto) standard.

Since I wrote this feature request Micha also highlighted the requirement to determine the scope of a preference defined in a topic, without considering the context of that topic i.e. ignoring web prefs etc.

-- CrawfordCurrie - 19 Apr 2012

. and Web. and %USERSWEB% might work technically, but they are not good for communicating with the reader of the tml - dots are like quotes and commas - hard to see, but would have a too large impact on the result.

y, local topic scope vs topic scope or something.

Too many things are converging (in a good way) - I can't see me having a long enough quiet moment until Monday, but I wonder if we need to FormaliseTheProgrammingLanguage

-- SvenDowideit - 19 Apr 2012

No objections, so accepted under the the 14 day rule.

-- CrawfordCurrie - 25 Apr 2012
Topic revision: r6 - 08 Nov 2012, SvenDowideit - This page was cached on 13 Jan 2021 - 20:11.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy