[Zope] Beginner DTML question: dereferencing a variable

Martin Dougiamas martin@complex.curtin.edu.au
Tue, 6 Apr 1999 19:00:27 +0800 (WST)


Martin Dougiamas wrote:
> I want to check if a folder of that name already exists
> under the current folder, so I can decide to create it or not.
>
> Intuitively, I first tried:
>
> <!--#if "theusername"-->
>   <H3>FOLDER EXISTS</H3>
> <!--#else-->
>   <H3>FOLDER DOES NOT EXIST</H3>
> <!--#/if-->

I seem to found a solution myself.  This seems to work:

<!--#if "_.has_key(theusername)"-->
  <H3>FOLDER <!--#var "theusername"--> EXISTS</H3>
<!--#else-->
  <H3>FOLDER <!--#var "theusername"--> DOES NOT EXIST</H3>
<!--#/if-->

...as long as there's not a object with that name UP the
hierarchy, I suppose.

If there's a cleaner way to do this I'd still like to know it.

Cheers!
Martin