[Zope] Printing value based on SQL table lookup

Michael Wang-Helmke mhelmke@play.com
Tue, 29 Jun 1999 17:09:50 -0700


hi all,

I have some database tables being accessed via SQL where each record is of the form (key, value).  In my Zope product in development, I keep track of all information by key but for user display purposes, I want to show the value.

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?

thanks,

Michael Wang-Helmke