[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Creating Basic Zope Applications

nobody@nowhere.com nobody@nowhere.com
Tue, 27 Aug 2002 13:16:54 -0400


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

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

      Finally let's add the ability to sort this list by file name or by
      modification date. Change the *index_html* method again::

        <dtml-var standard_html_header>

        <h1>File Library</h1>

        <table>
          <tr>
            <th><a href="&dtml-URL0;?sort=name">File</a></th>
            <th><a href="&dtml-URL0;?sort=date">Last Modified</a></th>
           </tr>

        <dtml-if expr="_.has_key('sort') and sort=='date'">
          <dtml-in expr="objectValues('File')" 
                   sort="bobobase_modification_time" reverse>
            <tr>
               <td><a href="&dtml-absolute_url;"><dtml-var title_or_id></a></td>
               <td><dtml-var bobobase_modification_time fmt="aCommon"><td>
            </tr>
          </dtml-in>
        <dtml-else>      
          <dtml-in expr="objectValues('File')" sort="id">
            <tr>
               <td><a href="&dtml-absolute_url;"><dtml-var title_or_id></a></td>
               <td><dtml-var bobobase_modification_time fmt="aCommon"><td>
            </tr>
          </dtml-in>
        </dtml-if>

        </table>

        <dtml-var standard_html_footer>  

        % Anonymous User - Aug. 20, 2002 9:34 am:
         Could somebody explain to me what that _.has_key()-function does so that I might be able to reuse it in
         another application?

        % krump - Aug. 27, 2002 1:16 pm:
         "has_key('KeyName')" is a normal Python dictionary method. Normally you would create a Python dictionary and
         then look to see if it had a particular item in it by using something like:
         DictionaryName.has_key('KeyName'). The underscore in front of the method must be something Zopish.
         Is the HTML table showing up for everyone else? That is the only part of the "File" index_html DTMLmethod
         that is not working for me.