[Zope-DB] How can I dynamically generate a Z Search Interface?

Dieter Maurer dieter@handshake.de
Wed, 4 Sep 2002 20:11:40 +0200


Tena Sakai writes:
 > ....
 > 
 > Let me reinstate the problem concisely.  I have a
 > dtml method which gives a form.  When user checks
 > or unchecks checkboxes and press submit button,
 > an action (which is also a dtml method) is invoked.
 > That action collects data (column names of a table)
 > dynamically.  How would I do actuall database
 > query using this very data?
You have a (static) Z SQL method that accepts "this very data"
as parameters and build the corresponding SQL command.

One way would be:

  Z SQL Method:

    Arguments: SQLCommand
    Body: <dtml-var SQLCommand>

  Thus, you pass in the complete SQLCommand (which you constructed
  out of your data, as it fits your needs).

Of cause, this method is dangerous:

   When you are not careful, it could be called with "delete from XXXX"
   and your table "XXXX" would be empty.

Therefore, I would try to avoid such a general method.

I would probably use:

  Z SQL Method:
    Arguments: KeywordArgs
    Body:      Build the SQL command from *KeyWordArgs*

  I would call it in the following way.

    args['a']= something
    args['b']= some_list
    ...
    return myZSQLMethod(KeywordArgs=args)


Dieter