[Zope] Printing value based on SQL table lookup

Rob Page rob.page@digicool.com
Thu, 1 Jul 1999 06:52:49 -0400


I can't recall I or anyone else has already taken a stab at this but
here it goes (again?)... I've really got to get some sleep...  :^)

> I have SQL of the following form to do the lookups:
> 
> product_list_by_key_sql(item_id)
> 
> SELECT product
> FROM products
> WHERE key = <!--#sqlvar item_id type=int-->
> 
> and I intended to use it in my DTML pages as follows:
> 
> <!--#var "product_list_by_key_sql(item_id=prod_key)-->
> 
> where prod_key is the product key.
> 
> However, this just gives me an object reference for the 
> Database result class.  With further strange hacking I came 
> up with this
> 
> <!--#var "product_list_by_key_sql(item_id=prod_key)[0]['product']"-->
> 
> which I understandably don't like very much.  (nor do I quite 
> understand it).
> 
> I am fairly new to Zope but not Python.  How would others do this?

Try:

<!--#in product_list_by_key_sql-->
  <!--#var product-->
<!--#/in-->

--Rob