[Zope] Tokens: Please help

Evan Simpson evan@4-am.com
Mon, 31 Jan 2000 11:04:12 -0600


cesare@planningsrl.it wrote:

> Can someone tell me how can I have a form in which the user can insert
> wordS and I return the list of records (on db) that contain in a certain
> field one of those words.

There are two separate but related issues here:

1.  Choosing how to return the words from the form

Most of the time, you will want your form to return the words as a list of
strings, and there are several ways to do this.  You can use a textarea
named 'words:lines', an input field named 'words:tokens', or multiple input
fields all named 'words:list'.

2.  Choosing how to query the database

Once you have this list in Zope, you'll want to construct your query.  I get
the idea that you want to produce something like "(f containing 'cats') or
(f containing 'dogs')" in your WHERE clause.  Try this:

WHERE <dtml-in words>
(fieldname containing <dtml-sqlvar sequence-item type=string>)
<dtml-unless sequence-end> or </dtml-unless>
</dtml-in>

One last issue to consider is that if your SQL parameter is just 'words',
the form will work fine but the test page will fail.  Make your parameter
'words:tokens' so that the Test input page is doing the same thing as your
form (use ':tokens' even if you used ':lines' or ':list' or your form; the
Test input page isn't smart enough to provide a textarea or multiple input
fields).

Cheers,

Evan @ 4-am (and soon digicool)