[Zope] How does dtml-sqlgroup really work?

David Burton eloquence@eloquent-designs.f2s.com
Mon, 10 Jun 2002 10:11:58 +0100


That's where you need the 'optional' argument - e.g. <dtml-sqltest company_name op=like type=nb optional>

so that you don't get key errors when the variable doesn't exist.

HTH,
David Burton

07/06/2002 17:53:30, "Jorge O. Martinez" <jmartinez@eMediaMillWorks.com> wrote:

>Hi Thomas:
>
>However, wouldn't that defeat the purpose of sqltest? I mean, precisely I want 
>to be able to only set one (ticker, company_name, etc.), or none, and have 
>sqltest evaluate them, and ignore the ones not set, or that do not exist, and 
>then, have it dynamically create my query based on the one that do exists and 
>is set.
>
>BTW, I used David's suggestion, and that seems to have improved things, as the 
>logic now at least works in the 'test' mode, but I am still not getting it to 
>work with the rest of the code, but there might be some other thing I may have 
>missed there.
>
>Thanks for the tips,
>
>Jorge M.
>
>Thomas B. Passin wrote:
>> industry_group is supposed to be a variable known to the Zope namespace.  If
>> this variable doe snot exist, you would get the error you quote.  Make sure
>> you have created the variable and assigned it a value.
>> 
>> Cheers,
>> 
>> Tom P
>> 
>> [Jorge O. Martinez]
>> 
>> 
>>>Not sure if this is a DB question, or DTML question, so I'm sending it to
>> 
>> the
>> 
>>>general Zope list.
>>>
>>>I've been banging my head over this relatively simple query, which (if my
>>>understanding of the dtml-sqltest tag is correct), should be fine. The
>> 
>> idea is
>> 
>>>simple, get 3 columns from company_index, and display the results, if
>> 
>> there's
>> 
>>>further constrains set (like ticker, company_name, etc.), taylor the query
>>>accordingly:
>>>
>>>select company_name,ticker,primary_exchange
>>>  from
>>>company_index
>>><dtml-sqlgroup where>
>>><dtml-sqltest ticker op=eq type=nb>
>>><dtml-sqltest company_name op=like type=nb>
>>><dtml-sqltest industry_group op=eq type=nb>
>>><dtml-sqltest industry_subgroup op=eq type=nb>
>>><dtml-sqltest market_cap op=eq type=nb>
>>><dtml-sqltest market_sector op=eq type=nb>
>>><dtml-sqltest primary_exchange op=eq type=nb>
>>></dtml-sqlgroup>
>>>
>>>but it's not happy. It keeps displaying errors like this:
>>>
>>>*************
>>>
>>>Zope has encountered an error while publishing this resource.
>>>
>>>Error Type: KeyError
>>>Error Value: industry_group
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Zope maillist  -  Zope@zope.org
>> http://lists.zope.org/mailman/listinfo/zope
>> **   No cross posts or HTML encoding!  **
>> (Related lists - 
>>  http://lists.zope.org/mailman/listinfo/zope-announce
>>  http://lists.zope.org/mailman/listinfo/zope-dev )
>> 
>
>
>
>-- 
>Jorge O. Martinez
>MIS Senior Associate
>eMediaMillWorks
>1100 Mercantile Lane, Suite 119
>Largo, MD 20774
>E-mail  => jmartinez@eMediaMillWorks.com
>Phone   => (301)883-2482 ext. 105
>Fax     => (301)883-9754
>
>
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://lists.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists - 
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>
"Into the abyss we stare, hoping that the abyss does not gaze so intently upon us"