[Zope] Creating a List from a SQLMethod
Jim Fulton
jim@digicool.com
Tue, 04 Jan 2000 09:58:05 -0500
Timothy Grant wrote:
>
> Hi,
>
> I've got a page that displays a <select> list based on the return values
> from a SQLMethod. It works exactly as expected.
>
> I have now determined a need to display the exact same <select> multiple
> times on the same page.
>
> The original code to build the select list looks something like this:
>
> <select name="Category">
> <option>(None)
> <dtml-in CategorySelectQuery start=query_start>
> <option><dtml-var category>
> </dtml-in>
> </select>
>
> I thought I could do something like the following:
> <select name="Category">
> <option>(None)
> <dtml-in CategorySelectQuery start=query_start>
> <option><dtml-var category>
> <dtml-call "REQUEST.set('catlist:list', category)">
> </dtml-in>
> </select>
>
> And then later on the page do this
>
> <select name="category">
> <dtml-in catlist>
> <option><dtml-var "_['sequence-item']">
> </dtml-in>
> </select>
>
> Unfortunately Zope returns a Key error on catlist.
>
> What am I doing wrong?
You are setting a key, "catlist:list", rather than "catlist".
The ":list" is only meaningful in an HTML form variable.
You could use a with or let tag, as in:
<dtml-with "_(results=CategorySelectQuery())">
<select name="Category">
<option>(None)
<dtml-in results start=query_start>
<option><dtml-var category>
</dtml-in>
</select>
...
<select name="category">
<dtml-in results>
<option><dtml-var category>
</dtml-in>
</select>
</dtml-with>
Jim
--
Jim Fulton mailto:jim@digicool.com Python Powered!
Technical Director (888) 344-4332 http://www.python.org
Digital Creations http://www.digicool.com http://www.zope.org
Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission. Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.