[Zope] Default values in ZSQL methods
Joel Burton
jburton@scw.org
Tue, 13 Mar 2001 11:51:22 -0500 (EST)
I have a ZSQL method, by_id, which accepts a 'staffid' as
staffid:int=0
(allow an integer-only id, but default to zero.)
The method is:
select *
from vlkpstaff
<dtml-if "staffid > 0">
where staffid=<dtml-sqlvar staffid type=int>
</dtml-if>
(if a real staff ID was passed, use it in the where statement, otherwise
show all records)
The works great, even with direct traversal, so I can say things like
http://www.foo.com/staffFolder/by_id/100
to get staff ID#100.
However, in a DTML method, 'roster', I say:
<dtml-in by_id>
... show staff info here ...
</dtml-in>
hoping to show *all* staff. Instead, I get *none*.
If I call it explicity, as
<dtml-in "by_id('staffid':0)">
...
</dtml-in>
it works fine, but this is a bit ugly, and it creates dependencies on
my keeping this staffid field w/the same name, etc.
Of course, I could have two queries, by_id, and showAll, and this work
fine, but again, it forces me to keep two queries in sync when keeping
just one in sync feels right.
Is there a way out of this little mess?
--
Joel Burton <jburton@scw.org>
Director of Information Systems, Support Center of Washington