[Zope] ZSQL Method Question

Jim Sanford jsanford@atinucleus.com
Fri, 25 Feb 2000 09:36:59 -0600


Your question intrigued me so I played around a little.  

This works:

Number of rows in query = <dtml-var "_.len(t1)"><br>
<dtml-with "_.namespace(t1=Query.OrderItems())">
<dtml-var "t1[0].orderdetid" html_quote> <dtml-var "t1[0].engname" html_quote><br>
<dtml-var "t1[1].orderdetid" html_quote> <dtml-var "t1[1].engname" html_quote><br>
<dtml-var "t1[2].orderdetid" html_quote> <dtml-var "t1[2].engname" html_quote><br>
<dtml-var "t1[1].orderdetid" html_quote> <dtml-var "t1[1].engname" html_quote><br>
<dtml-var "t1[5].orderdetid" html_quote> <dtml-var "t1[5].engname" html_quote><br>
</dtml-with>

you will, of course need to substitute your own query and column names
----- Original Message ----- 
From: Carlson, Christopher W. <Christopher.W.Carlson@ct.sgcna.com>
To: <zope@zope.org>
Sent: Thursday, February 24, 2000 4:05 PM
Subject: RE: [Zope] ZSQL Method Question


This wasn't originally my line of questioning, but it inspired me...and I
subsequently became stuck.

I've done the following:
<dtml-call "REQUEST.set('rows',MaintNames())">
and successfully set 'rows' to the value returned by the SQL Method
MaintNames.  I can <dtml-in rows> through the list and do fun stuff.

After scouring the documentation, I still can't find how to select the
values from an arbitrary row, say row 3 without combining <dtml-in> and
<dtml-if> while using the sequence-item value.  Is there a more elegant way?

--- Chris

-----Original Message-----
From: Matt Goodall [mailto:mgg@isotek.co.uk]
Sent: Wednesday, February 23, 2000 11:09 AM
To: Chris Withers
Cc: Zope Mailing List
Subject: Re: [Zope] ZSQL Method Question


Chris Withers wrote:

If your SQL Method is called sql_GetAll then you can do something like:

<!-- Get the rows -->
<dtml-call "REQUEST.set('rows',sql_GetAll())">

<!-- Display the total number of rows -->
<dtml-var "_.len(rows)">

<!-- Display the records -->
<dtml-in rows>
  <!-- whatever -->
</dtml-in>

That way you can unlink the code that writes the hidden form input field
from the dtml-in code.

HTH.

/Matt

_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )