RE: [Zope] Beginner DTML question: dereferencing a variable
-----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 :-(
On Tue, 6 Apr 1999, Michel Pelletier wrote:
<!--#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-->
Is the setting of a variable needed? <!--# unless "theusername in objectIds('Folder')"--> or <!--# if "theusername not in objectIds('Folder')"--> will work too. Pavlos
participants (2)
-
Michel Pelletier -
Pavlos Christoforou