[Zope] Calling a zsql with optional fields

Laura McCord Laura.McCord at doucet-austin.com
Tue Oct 19 12:11:10 EDT 2004


Ok. I redesigned my zsql method to be much simpler:

 select * from host
 <dtml-sqlgroup where>
  <dtml-sqltest name="location1" column="site" type="nb" optional>
   <dtml-or>
    <dtml-sqltest name="location2" column="site" type="nb" optional>
   <dtml-or>
    <dtml-sqltest name="location3" column="site" type="nb" optional>
   <dtml-and>
  <dtml-sqlgroup>
   <dtml-sqltest name="usetype1" column="UseType" type="nb" optional>
   <dtml-or>
    <dtml-sqltest name="usetype2" column="UseType" type="nb" optional>
    <dtml-or>
     <dtml-sqltest name="usetype3" column="UseType" type="nb" optional>
   </dtml-sqlgroup>
  <dtml-and>
   <dtml-sqltest name="active" column="Active_Inactive" type="int"
optional>
</dtml-sqlgroup>

My form is a combination of checkboxes:
   <form action="resultsPage">
    <table>
    <tr>
    <td>Select any of the following combinations:</td>
    </tr>
    </table>
    <table>
    <tr>
    <td>Active:</td>
    <td><input type="checkbox" name="active" value="1"
checked="checked">Active</td>
    </tr>
    <tr>
    <td>Site:</td>
    <td><input type="checkbox" name="location1" value="aus">Austin </td>
    <td><input type="checkbox" name="location2"
value="ca">California</td>
    <td><input type="checkbox" name="location3"
value="mass">Massachusetts</td>    
    </tr>
    <tr>
    <td>UseType:</td>
    <td><input type="checkbox" name="usetype1"
value="server">Server</td>
    <td><input type="checkbox" name="usetype2" value="cad"> CAD</td>
    <td><input type="checkbox" name="usetype3" value="base">Base</td>
    </tr> 
    <tr>
    <td><span><input type="submit" class="submitLink"
value="save"></span></td>
    </tr>
    </table>
   </form>

The only problem I am having is bridging the two in order to get my
results. I have a dtml method that I am trying to process the zsql
method but I don't think I am doing it correctly.

<dtml-call expr="findResults(location1=location1, ...,
usetype1=usetype1, ...,active=active)">

 But, with the above if location2 or any of the boxes are not selected I
am getting an error that they are not defined. How do I correct this
problem?

Thanks You.


More information about the Zope mailing list