[Zope] A conditional dtml-in tag?
Dieter Maurer
dieter at handshake.de
Tue Feb 17 14:26:55 EST 2004
RI Dunfey wrote at 2004-2-16 16:32 +0000:
>I have a dtml page which displays the results of a sql query:
>
><dtml-in expr="my_query(category1=category1, category2=category2)">
><TR><TD>
><dtml-var NAME>
></TR></TD>
></dtml-in>
>
>The values that are passed to the query are obtained from the request object.
>If the value for category2=None then I want to leave category2 out of the sql
>query as below:
I suggest you do the logic in a "Script (Python)". It is far easier
there. It will look like:
request = container.REQUEST
category1 = request.get('category1')
category2 = request.get('category2')
query = { 'category1' : category1 }
if category2: # or whatever logic you want
query['category2'] = category2
return context.my_query(**query) # here you call your Z SQL Method
--
Dieter
More information about the Zope
mailing list