[Zope-DB] Selective namespace access for SQL method

Mark Evans mark.evans.b@bayer.com
Sun, 4 May 2003 22:28:20 -0700

Hi all,

I have a large ZSQL method (partially shown below) called buildPhraseList:
arguments = dbt, origin, protein_gene_type + 10 more

select phrase_name
from lims_sys.phrase_entry
<dtml-sqlgroup where>
phrase_id in (
  select phrase_id
  from  lims_sys.schema_field
  <dtml-sqlgroup where>
   <dtml-if dbt>
     schema_table_id = 138 and database_name = 'U_DBT'
   <dtml-elif origin>
     schema_table_id =138 and database_name ='U_ORIGIN'
   <dtml-elif protein_gene_type>
     schema_table_id =138 and database_name ='U_PROTEIN_GENE_TYPE'
order by order_number

What this is supposed to do is build a phrase list from the appropriate table,
depending on which variable was passed in.  I'm using this to build components
of a form.  The variables in the arguments list are coming from the results of a
previous ZSQL query, so many of the input variables are already floating in the
namespace.  I have tried using
<dtml-with origin only>
    <select name=foo size=1>
         <dtml-in expr="buildPhraseList(origin)">
            do stuff
etc. but because dbt is in the namespace already that is the only list I can get
out.  If some of the variables are missing from the namespace, then there is no
restriction and I get all values back in one list.  This method works perfectly
when tested from the ZMI test tab.  Why doesn't 'with' properly restrict the sql
method to just one input?  Is there another way to have a sql method be able to
take more than one variable, but only feed it one at a time?

Thanks in advance,

Mark Evans