Tags:
create new tag
view all tags

Proposal: Simple Operators in IF: allows, istopic, isweb

I created three simple operators in %IF.

allows 'X' allows 'Y' is true if web/topic 'X' exists and allows access mode 'Y' for the current user. Web access rights are only checked if there is no topic called 'X'.
istopic istopic 'X' is true if topic 'X' exists
isweb isweb 'X' is true if web 'X' exists

Check access permissions

You %IF{"'%TOPIC%' allows 'change'" then="can" else="cannot"}% change this topic.
You %IF{"'Sandbox.TestTopic' allows 'change'" then="can" else="cannot"}% change Sandbox.TestTopic.
You %IF{"'Sandbox' allows 'change'" then="can" else="cannot"}% change Sandbox web

Check existance

Topic Sandbox.TestTopic %IF{"istopic 'Sandbox.TestTopic'" then="exists" else="does not exist"}%
Web Sandbox %IF{"isweb 'Sandbox'" then="exists" else="does not exist"}%

The work is checked in, and thoroughly unit-tested, but can be reverted if this is rejected; i am concious we are close to a release.

-- Contributors: CrawfordCurrie - 27 Aug 2007

Discussion

Proposal was accepted at FreetownReleaseMeeting2007x08x27. It sort of broke the feature freeze but it was - as an exception - accepted because it was the a means to cure some bugs and it was a very narrow scope contained enhancement followed up by a large set of unit tests.

-- KennethLavrsen - 28 Aug 2007

  1. What I would really want is a simple check if the current topic %TOPIC equals a given name.
  2. The new selector istopic has a different meaning. Wouldn't exists be a more logical term?

-- ArthurClemens - 04 Sep 2007

What's wrong with %IF{"'%TOPIC%'='SimpleOperatorsInIF'" then="Yes" else="No"}% ? (renders to: Yes)

  • Because I got confused again and it didn't work. Until I just realised I need to write %BASETOPIC%... Sorry. -- ArthurClemens - 04 Sep 2007

I used istopic so I could have the symmetrical isweb. I considered topicexists and webexists instead, but decided they were too much typing.

-- CrawfordCurrie - 04 Sep 2007

If we call a topic suddenly page and webs wikis this will become ispage and iswiki right? wink

-- FranzJosefGigler - 04 Sep 2007

Tip of the iceberg, my dear chap. Just the tip of the iceberg.

-- CrawfordCurrie - 05 Sep 2007

  • Request - isattached operator? For checking existence of attachments

%IF{" isattached MyResume.pdf" then="Please Hire Me" else=""}%

Ps. When at work, I will post a code snippet I have tucked into a catchall plugin I use for miscellaneous functions.

-- CraigMeyer - 02 Dec 2007

Why the ambiguity of "'Sandbox' allows 'change'"? What if a Sandbox topic exists in the current web? Why not make it orthogonal to other parts of TWiki and require a dot to indicate a web? In the Go box you type Sandbox. ("sandbox" + dot) to jump to the Sandbox web. I think by aligning the syntax we can avoid confusion.

-- PeterThoeny - 03 Dec 2007

Oh a dot after a name in the jumb box disambiguates webnames from topic names. Did not know that existed wink

-- MichaelDaum - 03 Dec 2007

TWiki has so many features, it's easy to miss. See the docs of the all mighty GoBox. (BTW I use the Otherweb.partofname syntax all the time. Especially useful to navigate a TWiki with > 50K pages.)

-- PeterThoeny - 03 Dec 2007

Still not mighty enough, as it needs a second input field to do searching ... which is bad from a usability point of view. Have a look at NatSearch for a solution. Give it a try at the WikiRing.

-- MichaelDaum - 03 Dec 2007

Edit | Attach | Watch | Print version | History: r13 < r12 < r11 < r10 < r9 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r13 - 2007-12-03 - MichaelDaum
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.