[Zope] How to pass arguments to ZSQL-Methods?

Jason Wong jwong@digitalview.com.hk
Mon, 3 Apr 2000 16:36:37 +0800


No joy. Same error.

Perhaps if I explain what I'm trying to do someone can suggest an
alternative/better/working solution.

I have a need to create a lot of drop-down boxes. These will be populated
from a ZSQL method. This ZSQL method can take one of two forms (more may be
needed later, I'm not sure):

qry_generic:
SELECT DISTINCT <column> FROM <table> WHERE <criteria>

qry_specific:
SELECT * FROM <table> WHERE Status='Current' AND <qry_item> LIKE <criteria>

arguments to the ZSQL method are enclosed in < >.


I have a DTML method called Create_DDB which creates the drop-down box. It
takes these arguments:
   list_name     : The name of the drop down box
   extra_item    : Extra item to add to list if any
   extra_value   : Value of the extra item
   qry_name      : Name of the ZSQL method to use
   qry_item      : Item to query for
   qry_table     : Table to query
   qry_criteria  : The Where clause for the query

I have some logic which in the case that qry_name is qry_generic then it
maps the following:
qry_item     -> column
qry_table    -> table
qry_criteria -> criteria

if qry_name is qry_specific then:
qry_item     -> qry_item
qry_table    -> table
qry_criteria -> criteria

It then calls the ZSQL method, which if you're still reading, is where I am
stuck.



The idea is whenever I want to create a drop-down box I would use something
like:

<dtml-var "Create_DDB(_.None, _, list_name='Controller_Models',
qry_name='qry_specific', qry_item='Model', qry_table='Controller Info',
qry_criteria='1=1')">


So, is it possible to do what I have outlined above?

Has anyone written a generic library of methods for creating standard stuff
like drop-down boxes(!), tables, lists, option boxes etc?

Any input appreciated.

thanks
-
Jason Wong


> At 02:47 PM 4/3/00 +0800, you wrote:
> >I'm trying to pass some arguments to a ZSQL method using the following:
> >
> ><dtml-in "_[qry_name](_.None, _, column='Model', table='Panels',
> >criteria='1=1')">
>
> try:
>
> <dtml-let query="_[qry_name]">
>      <dtml-in "query(column='Model', table='Panels', criteria='1=1')">
>           ...
>      </dtml-in>
> </dtml-let>
>
> But my question is: Why do you get in a situation like that in the first
> place. It seems like if you redesign a little, you should be able to
> eliminate the situation.
>
> Regards,
> Stephan
> --
> Stephan Richter - (901) 573-3308 - srichter@cbu.edu
> CBU - Physics & Chemistry; Framework Web - Web Design & Development
> PGP Key: 735E C61E 5C64 F430 4F9C 798E DCA2 07E3 E42B 5391
>