[Zope] Using MySQL results for condition checking in ZPT

Ben M. Thomas ben@smallercircle.com
23 Feb 2003 03:27:02 -0600


I have created a ZSQL method which expands the query results depending
upon the variables supplied:

SELECT <dtml-if "Category != '%' or fullSearch">Category,
</dtml-if><dtml-if "Notes != '%' or fullSearch">Notes,
</dtml-if><dtml-if "Language != '%' or fullSearch">Language,
</dtml-if><dtml-if fullSearch>ISBN, UPC, Cost, Resale, Rate, Rent_Per,
Keywords, </dtml-if>ItemID, Type, Name, Status FROM Movie_Records INNER
JOIN Movie_Inv ON Movie_Records.MovieID = Movie_Inv.MovieID WHERE Status
<=1 AND Name LIKE <dtml-sqlvar Name type="string"> AND Language LIKE
<dtml-sqlvar Language type="string"> AND Category LIKE <dtml-sqlvar
Category type="string"> AND Notes LIKE <dtml-sqlvar Notes type="string">
AND Keywords LIKE <dtml-sqlvar Keywords type="string"> ORDER BY Type,
Language, Name ASC

This works splendidly. My problem is displaying the results while
dynamically formating the table. If the column has no results then I'd
like to omit it.

My TAL condition that I'm attempting to use is something like:

For the Table Header:
<span tal:condition="result/Category">
<th>Category</th>
</span>

And the Body:
<span tal:condition="result/Category">
<td><span tal:replace="result/Category">Category goes here</span></td>
</span>

This seems very simplistic to me, but Zope doesn't agree with the way
I'm access the variables. I think that my understanding of
"result/Category" and Zope variables is fundamentally flawed, but I
can't seem to find any clear documentation on this aspect of Zope.

Can someone help me get a clue?

-- 
Ben M. Thomas <ben@smallercircle.com>