[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Advanced Page Templates

webmaster@zope.org webmaster@zope.org
Thu, 26 Sep 2002 13:41:47 -0400


A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/AdvZPT.stx#3-93

---------------

      You can do the same thing more easily with an exists
      expression::

        <h4 tal:condition="exists:request/form/errmsg"
            tal:content="request/form/errmsg">Error!</h4>

        % Anonymous User - June 28, 2002 11:55 am:
         > Isn't <h4 tal:condition="request/form/errmsg" ...> the same
         > since a non existing variable returns false (see section
         > 'Not Expressions') -TD

         I thought so, too, but it turns out a non-existing variable inside a condition raises an exception, so
         'exits:' is necessary in the condition. -WillemB

        % Anonymous User - June 28, 2002 12:00 pm:
         But you can also use 'nothing' in the condition instead of 'exists:':
           <div tal:condition="non_existing | nothing">...</div>  -WB

        % Anonymous User - Sep. 26, 2002 1:41 pm:
         *PExists*   <==> <dtml-if name="..."> treats non-existence as falsehood.