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

Tena Sakai tena.sakai.b@bayer.com
Thu, 5 Sep 2002 11:31:48 -0700


Dear Dieter,

Many thanks for your response and advice.  It finally registered
in my brains.  I can also see that it is dangerous to use Z SQL
method in this fashion.  I am interested in pursuing a use of
External Method.  Would you have any comments/advice for
such?

Regards,

Tena Sakai


                                                                                                                          
                      Dieter Maurer                                                                                       
                      <dieter@handshake        To:       "Tena Sakai" <tena.sakai.b@bayer.com>                            
                      .de>                     cc:       zope-db@zope.org                                                 
                      Sent by:                 Subject:  Re: [Zope-DB] How can I dynamically generate a Z Search          
                      zope-db-admin@zop         Interface?                                                                
                      e.org                                                                                               
                                                                                                                          
                                                                                                                          
                      09/04/2002 11:11                                                                                    
                      AM                                                                                                  
                                                                                                                          
                                                                                                                          




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

_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://lists.zope.org/mailman/listinfo/zope-db