[Zope] Simple ZSQL question -- variable expansion in dtml-if?
Jim Sanford
jsanford@atinucleus.com
Tue, 11 Jan 2000 07:51:22 -0600
SELECT * FROM table
<dtml-if "X==1">
WHERE col=1
<dtml-elif "X==-1">
WHERE col=0
</dtml-if>
should work. It assumes that X will only be between -1 and 1.
__________________________________________________________________
Jim Sanford
. Database/Web 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
Source Code, No Royalties, Any CPU...It just make sense !
__________________________________________________________________
----- Original Message -----
From: J C Lawrence <claw@kanga.nu>
To: <zope@zope.org>
Sent: Tuesday, January 11, 2000 3:18 AM
Subject: [Zope] Simple ZSQL question -- variable expansion in dtml-if?
I'm attempting to write a ZSQL method which has the following
behaviour (the exact case below is a little more detailed):
When the passed X parameter is 1 it issues the following SQL:
SELECT * FROM table WHERE col=1
When X parameter is 0:
SELECT * FROM table
And when X is -1:
SELECT * FROM table WHERE col=0
My attempted ZSQL is below (a little more complicated that the
above). CatParent and Approved are passed in arguments to the
method:
SELECT *
FROM Categories
<dtml-sqlgroup where>
<dtml-sqltest CatParent type=int>
<dtml-and>
<dtml-if expr="Approved == 1">
<dtml-sqltest Approved type=int>
</dtml-if>
<dtml-if "Approved == -1">
Approved=0
</dtml-if>
</dtml-sqlgroup>
ORDER BY CatName
The problem is that the "Approved" variable in the dtml-if clauses
does not appear to be getting expanded to its value. It doesn't
improve if I replace it with "_['Approved']". What am I missing?
While I'm new to Zope I *think* that should work per what I've read.
Instead for all values of Approved I get:
SELECT * FROM Categories WHERE CatParent=### ORDER BY CATNAME
and Approved never gets mentioned.
Is there a way to accomplish the above within a single ZSQL method,
or must I break it out?
--
J C Lawrence Home: claw@kanga.nu
----------(*) Other: coder@kanga.nu
--=| A man is as sane as he is dangerous to his environment |=--
_______________________________________________
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 )