[Zope] Beginner DTML question: dereferencing a variable

Michel Pelletier michel@digicool.com
Tue, 6 Apr 1999 10:28:04 -0400


> -----Original Message-----
> From: Richard Wackerbarth [mailto:rkw@dataplex.net]
> Sent: Tuesday, April 06, 1999 9:37 AM
> To: Michel Pelletier
> Cc: zope@zope.org
> Subject: RE: [Zope] Beginner DTML question: dereferencing a variable
> 
> 
> 
> 
> On Tue, 6 Apr 1999, Michel Pelletier wrote:
> > > 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.
> 
> > <!--#in "objectIds('Folder')-->
> >   <!--#if "id == theusername"-->
> >     Folder Exists
> >   <!--#/if-->
> > <!--#/in-->
> > 
> > You want to use a DTML Method to get the expected result.
> 
> OK, that handles the case where you want to find the object and do
> something to it.
> 
> How do you propose to handle the opposite case (which Dougiamas-san
> requested) -- do something if the entry DOES NOT exist.
> 

<!--#with _.namespace(folders=objectIds('Folder'))-->
  <!--#if "theusername not in folders"-->
	No folder named <!--#var theusername-->
  <!--#else-->
	Go to folder <a href="<!--#var theusername-->"><!--#var
theusername-->
  <!--#/if-->
<!--#/with-->      

> IMHO, this calls for a local variable to set and test.
> 

which is essentialy what I did.

-Michel

> You might use REQUEST.set('I_found_the_folder' ...
> 
> However, the use of the global REQUEST namespace has its hazards :-(
>