Feature Proposal: Enable TML authors to see the topics that comprise the preference stack


The Preferences stack is a confusing concept, and it is helpful to be able to explicitly see the actual topics.

Description and Documentation





        VARIABLESTACK => sub { $_[0]->{prefs}->stringifyTopicNames() },

sub stringifyTopicNames {
    my ( $this, $key ) = @_;
    my $stack = $this->{main};
    my @r = $stack->getTopicNames();
    return join ',', @r;

sub getTopicNames {
    my $this = shift;
    my @ret;
    foreach my $back ( @{ $this->{'levels'} } ) {
        my $path = "ANON";
        if ($back->can('topicObject')) {
            my $obj = $back->topicObject();
            $path = $obj->getPath();
        push @ret, $path;
    return @ret;

-- Contributors: KipLubliner - 23 Oct 2012


I very much support this.

I've had the idea at a high level to build in 'explain' capability into Foswiki. That would, in principle, encompass all of the rendering process.

A full explain would show you how your viewed page was constructed by Foswiki phase by phase. This would be a useful debugging and learning tool.

Implementing this is an important step in this direction.

I must raise a feature request to cover the general 'explain' concept.

-- JulianLevens - 23 Oct 2012

i agree, explain is something we want going into the future. and this is one of those.

Kip - you're missing docco and unit tests - and then we can talk about formatting and how&where to use it smile

  1. it may be useful for there to be an ACL - to limit what the curious can find out
  2. i think that in the non-DENY case, it'll be safe, but if a topic is VIEW DENIED, its preferences have been evaluated, but the user should not know about it.

-- SvenDowideit - 23 Oct 2012

Hi guys, thanks for the comments. Sorry that I have been slow to respond - been quite busy. I am removing myself as a committed developer for now, because I don't think that this is a fully formed idea yet. Also because I will be on vacation for a few weeks. I don't like the idea of creating another single-purpose macro called 'VARIABLESTACK', and going along with Julian's idea ... maybe we can have an %EXPLAIN% macro which would hold this code. It could use a mechanism similar to %INCLUDE%'s includeHandlers

%EXPLAIN{what="Preferences" web="%WEB%" topic="%TOPIC%"

%EXPLAIN{what="Preferences" web="%WEB%" topic="%TOPIC%"
    action="showAllSettings" macro="MY_MACRO"}%
--> returns a table containing all values for %<nop>MY_MACRO% at all levels, with an asterisk next to the one that gets priority

And perhaps we could have these requests handled by Foswiki::ExplainHandlers::Preferences.pm. I don't know what Julian's full 'explain' idea is, but it might be useful to expose things via a TML macro.

@SD - I don't think any security checks are needed as the macro is not revealing non-public information. I.e. %VARIABLESTACK% displayed on Gothams.WebHome will return


But all this information can be determined by a careful study of PreferenceSettings (now that George has fixed the doc!).

-- KipLubliner - 26 Oct 2012

Topic revision: r5 - 16 Mar 2017, GeorgeClark
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