[Zope] Several users having problem accessing field names of a ZSQL Method

Jim Sanford jsanford@atinucleus.com
Thu, 8 Jun 2000 17:53:22 -0500


Below is the dtml code for a DTML document I have written
to return the results of any SQL query as an html table in groups of 50. 

Query.QuickSQL() takes as an argument a complete SQL statement.
"sqlStatement" is the REQUEST variable with the SQL statement.

 You can replace the query with your own ZSQL query.

getRes is an external python method, here it is:
------------------------------------
def getRes(self, zQry) :
    tvar1 = 'res=self.'+zQry
    exec tvar1
    tc1=res._schema.items()
    return tc1
----------------------------------------
this came out of a function module I wrote
that has all the imports at the top. You may
need to "import sys" for this to work. I don not
recall.
 __________________________________________________________________
 
              Jim Sanford
      .       Database Engineer
     / \  /   Accelerated Technology, Inc.
    /   /     720 Oak Circle Drive East
   /  /  \    Mobile, AL 36609
  / /     \   Voice: 334-661-5770  fax: 334-661-5788
 /         \  E-Mail: jsanford@atinucleus.com
              Web: http://www.atinucleus.com
  
 Nucleus.  All You NEED in an RTOS.  Royalty Free
 __________________________________________________________________

DTML Document Code below
_________________________________________________________________
<html><head><title>SQLResult</title></head><body>
<dtml-var sqlStatement><br><br>
<dtml-with "_.namespace(t1=getRes('Query.QuickSQL()'), t2=Query.QuickSQL())">
<dtml-call "REQUEST.set('colList',[])">
<dtml-in t1>
<dtml-call "colList.append([_['sequence-item'],_['sequence-key']])">
</dtml-in>
<dtml-call "colList.sort()">
<dtml-in t2 size=50 start=query_start>
<dtml-if sequence-start>
<dtml-if previous-sequence>
<a href="<dtml-var URL><dtml-var sequence-query
>query_start=<dtml-var previous-sequence-start-number>">
(Previous <dtml-var previous-sequence-size> results)
</a>
</dtml-if previous-sequence>
  <table border=1>
  <tr>
  <dtml-in colList>
  <dtml-let tlist="_['sequence-item']"
            tname="tlist[1]">
  <th><dtml-var tname html_quote></th>
  </dtml-let>
  </dtml-in>
  </tr>
</dtml-if>
<tr>
<dtml-let titem="_['sequence-item']">
<dtml-in colList>
<dtml-let tlist="_['sequence-item']"
           tcol="tlist[0]">
<td><dtml-var "titem[tcol]" html_quote newline_to_br></td>
</dtml-let>
</dtml-in>
</dtml-let>
</tr>
<dtml-if sequence-end>
</table>
<dtml-if next-sequence>
<a href="<dtml-var URL><dtml-var sequence-query
>query_start=<dtml-var
next-sequence-start-number>">
(Next <dtml-var next-sequence-size> results)
</a>
</dtml-if next-sequence>
</dtml-if sequence-end>
</dtml-in>
</dtml-with>
</body></html>