• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item3889: $EXISTS() should default to topic in current web

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension SpreadSheetPlugin Normal Closed   minor 4.2.0

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

See http://twiki.org/cgi-bin/view/Support/IfTopicExists

I am trying to test for the existence of a topic, the name of which contains underbars. This fails.

For example, if I put the following statement into topic MediaOpsProjectDetail_35_0704:

  %CALC{"$EXISTS(MediaOpsProjectDetail_35_0704)"}% 

it returns 0

-- TWiki:Main/VickiBrown - 13 Apr 2007

I've tried putting in quotes but haven't gotten anywhere.

I knw that this is, technically, not a WikiWord, but "non" WikiWords are supported by TWiki. The TOC plugin, for example, is perfectly happy to present a table of contents for MediaOpsProjectDetail_35_0704.

Code

%TOC{"MediaOpsProjectDetail_35_0704" depth="1"  title="Contents"}%

%CALC{$IF($EXISTS("MediaOpsProjectDetail_35_0704"), Yes, No)}%

Result

Contents

    * Summer Movies Sample
    * Forms Index
    * Milestones - Planning and Reviews
    * Notes 

No 

-- TWiki:Main.VickiBrown - 13 Apr 2007

Test if it works here:

%CALC{"$EXISTS(Item3889)"}%

results in: 1

%CALC{"$EXISTS(WebHome)"}%

results in: 1

It looks like SpreadSheetPlugin tests for wiki words.

-- TWiki:Main.ArthurClemens - 13 Apr 2007

All $EXISTS() does is this: $result = TWiki::Func::topicExists( "", $theAttr );. I suspect that this is a bug of the core TWiki, setting form fields accordingly.

-- TWiki:Main.PeterThoeny - 14 Apr 2007

As the Func documentation states, when topicExists is not passed a web name in the first parameter it defaults to looking up the Main web. In Arthur's example above, Main.Item3889 doesn't exist, but Main.WebHome does. It's doing exactly what it says on the tin.

The workaround is to specify the web in the call, e.g.

%CALC{"$EXISTS(%WEB%.Item3889)"}%

results in: 1

Resetting form fields accordingly.

CC

Perhaps the core tin says so, but the SpreadSheetPlugin documentation does not mention it.

This should be documented with a proper example.

In any case TWiki is lacking that "topic exists" is only available through a plugin. See Item3894.

I've updated the summary accordingly.

-- TWiki:Main.ArthurClemens - 14 Apr 2007

It is more intuitive to default to the current web, not the Main web. We can't change the spec of TWiki::Func::topicExists() because this would be an incompatible change and would break other plugins.

Recommended actions:

  1. Add note to TWiki::Func::topicExists() docs that it is recommended to add the name of the current web as the first parameter.
  2. Fix the SpreadSheetPlugin accordingly.

-- TWiki:Main.PeterThoeny - 14 Apr 2007

Both items are now done in SVN MAIN and Patch04x01.

-- TWiki:Main.PeterThoeny - 15 Apr 2007

Web.Topic is working. I can't seem to make it work without the Web specification (even after installing the latest version) but perhaps I need to do something more obvious to convince TWiki to load the new files?

-- TWiki:Main.VickiBrown - 23 Apr 2007

%22Test:%3cbr%20/%3e%20%20%20*%20%3d%%3cnop%3eCALC%7b%24EXISTS(%%3cnop%3eTOPIC%)= returns 1

  • 0 returns 0
" type="html"}%

-- TWiki:Main.PeterThoeny - 07 May 2007

NOTE: Above was added via comment plugin. I was not authenticated. TWiki asked me twice for authentication, then above content was posted. This content was supposed to get posted:

Test:

  • %CALC{$EXISTS(%TOPIC%)}% returns 1
  • %CALC{$EXISTS(%TOPIC%Xyz)}% returns 0

-- TWiki:Main.PeterThoeny - 07 May 2007

It works here. Vicki, please handle this as a TWiki:Support question. Could be related to mod_perl or speedy caching scripts.

-- TWiki:Main.PeterThoeny - 07 May 2007

ItemTemplate
Summary $EXISTS() should default to topic in current web
ReportedBy TWiki:Main.VickiBrown
Codebase 4.0.5, 4.1.2, ~twiki4
SVN Range TWiki-4.1.2, Fri, 13 Apr 2007, build 13369
AppliesTo Extension
Component SpreadSheetPlugin
Priority Normal
CurrentState Closed
WaitingFor

Checkins TWikirev:13402 TWikirev:13403
TargetRelease minor
ReleasedIn 4.2.0
Edit | Attach | Watch | Print version | History: r18 < r17 < r16 < r15 < r14 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r18 - 2008-01-22 - KennethLavrsen
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback