You are not logged in Log in Join
You are here: Home » Members » dean.jenkins » Generic Page Template for ZSQL Results - HTML » howto_view

Log in
Name

Password

 

Generic Page Template for ZSQL Results - HTML

 

Created by dean.jenkins . Last modified 2004-10-04 00:10:47.

A page template for displaying the results of any ZSQL method - the same way that manage_test does.

To use this code you need to put the code below in a 'page template' and call it thus 'http://yourzope/yourZSQLmethos/thiscode?yourparameters=whatever'

This has been adapted from ielbert's Generic Page Template for ZSQL Results which generates generic XML.


<html metal:use-macro="here/standard_template.pt/macros/page">
  <head>
    <title tal:content="template/title">The title</title>
  </head>
  <body metal:fill-slot="body">

    <h2 tal:define="description python:here.aq_parent.title_or_id()"
        tal:content="description" tal:on-error="error">
           description is taken from the Folder title
           <comment tal:omit-tag=""
                    text="Because of the Zope bug here/aq_parent does not work" />
     </h2>
     
    <h3 tal:content="python:'SQL query = ' + here(request, src__=1)"
        tal:condition="python:here.this()==here"
        tal:on-error="error">
        query source (if available)
        <comment tal:omit-tag=""
                 text="here.this()==here is true when we deal directly with ZSQL method - not via URL traverse" />
    </h3>

<table border="1">
    <content tal:define="result here; 
                         names result/names"
             tal:on-error="error" tal:omit-tag="">
<tr>
<th tal:repeat="name names" tal:content="name"></th>
</tr>

      <rowrepeater tal:define="dictionaries result/dictionaries"
                   tal:repeat="row dictionaries"
                   number="number"
                   tal:attributes="number repeat/row/number"
                   tal:on-error="error">
             <tr>
             <td tal:repeat="name names"
                 tal:content="python:row[name]"
                 tal:on-error="error">column
             </td>
             </tr>
      </rowrepeater>
    </content>


  </table></body>
</html>