[Zope] Re: [Zope-dev] zpt z-sql?

J Cameron Cooper jccooper@jcameroncooper.com
Thu, 19 Jun 2003 10:17:35 -0500


>
>
> What would be the syntax to call a z-sql (passing one or more 
> parameters) from a zpt?
>
>  
>
> The z-sql would retrieve a single row.  Fields from this row to be 
> shown in the zpt.
>
Just like any method that might return a list (we'll pretend more than 
one row is an option, it won't matter to you):

<span tal:repeat="sqlrow python:here.sqlmethod(paramA, paramB)">
  <span tal:content="sqlrow/fieldA">fieldA</span>
</span>

Things will vary: tags, parameters, fields, and you may want to use 
container instead of here, depending on what you're doing. But 
basically, that's it.

If you were certain there would be only one row, you could use 
tal:define instead of tal:repeat, and if you had no parameters, you 
could say

<span tal:repeat="sqlrow here/sqlmethod">
  <span tal:content="sqlrow/fieldA">fieldA</span>
</span>

       --jcc