[Zope-dev] Z SQL: "optional" isn't?
Kyler B. Laird
laird@ecn.purdue.edu
Fri, 26 May 2000 14:59:38 EST
I'd like to build a Z SQL method for *many*
people to use to list courses that we offer.
I don't want to require that all queries
using it understand all of the columns, but
I do want to be able to modify the query in
many ways.
So...after reading
http://yyy.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.5.3.html
optional
A flag indicating if the test is optional.
If the test is optional and no value is
provided for a variable, or the value
provided is an invalid empty string, then
no text is inserted.
I thought I could just use "optional"
with all of my sqltests.
select * from course_catalog
<dtml-sqlgroup where>
<dtml-sqltest subject type=nb optional>
<dtml-and>
<dtml-sqltest course_nbr type=nb optional>
<dtml-and>
<dtml-sqltest version type=nb optional>
<dtml-and>
<dtml-sqltest campus_code type=nb optional>
</dtml-sqlgroup>
This works only if I provide at least an empty
string for all values. If I don't provide a
value at all for one of the arguments, I get
Error, Bad Request: ['version']
SQL used:
Could not render the query template!
Traceback (innermost last):
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/Publish.py, line 224, in publish_module
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/Publish.py, line 189, in publish
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook
(Object: list_courses)
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/Publish.py, line 175, in publish
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/mapply.py, line 160, in mapply
(Object: manage_test)
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/Publish.py, line 112, in call_object
(Object: manage_test)
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Shared/DC/ZRDB/DA.py, line 347, in manage_test
(Object: list_courses)
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Shared/DC/ZRDB/DA.py, line 324, in manage_test
(Object: list_courses)
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Shared/DC/ZRDB/DA.py, line 426, in __call__
(Object: list_courses)
File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Shared/DC/ZRDB/Aqueduct.py, line 150, in _argdata
(Object: list_courses)
Bad Request: (see above)
Looking at Aqueduct.py, I don't understand why it's
not catching the "optional" arg. Using my limited
Python knowledge, I commented out lines 149 and 150
of Aqueduct.py and now it works great.
Once again, I'm glad that I can add these awful
kludges instead of waiting for the vendor, but this
is something that I hope is fixed soon.
--kyler