I am trying to use EXISTS() and AND(), and I am not findint it in the default namespace or in sqlobject. Pseudocode is:

Make a SQL query that will select every document in the selected section.
For each keyword in the CGI query:
    Make the SQL query require that all prior conditions be met, \
      and in addition that the index lists that the keyword is in the document.

The actual code is:

import cgi, cPickle, datetime, re, os, sgmllib, socket, sqlobject, sqlite, \
  string, sys, time, urllib

# ...

        query = sqlobject.Select(document_database, \
          ((document_database.q.section == restricted_section) | \
          (restricted_section == None)))
        for keyword in tokenize(string.lower(get_cgi("query"))):
            subquery = sqlobject.EXISTS(sqlobject.Select(document_database_keyword.q.id, \
              (database_document.q.id == \
              database_document_keyword.q.documentID) & \
              (database_document_keyword.q.word == keyword)))
            if query:
                query = sqlobject.AND(query, subquery)
                query = subquery

Where should I be getting EXISTS() and AND() from? Relatedly, are there other problems with this approach?

++ Jonathan Hayward, jonathan.hayward@pobox.com
** To see an award-winning website with stories, essays, artwork,
** games, and a four-dimensional maze, why not visit my home page?
** All of this is waiting for you at http://JonathansCorner.com

** If you'd like a Google Mail ( gmail.com) account, please tell me!