Creating a List from a SQLMethod
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? Thanks. -- Stand Fast, tjg. Chief Technology Officer tjg@exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. (503) 246-3630
>>>>>>EXCEPTIONAL MINDS, INNOVATIVE PRODUCTS<<<<<<<<<<<<
How about something like (untested) <select name="Category"> <option>(None)> <dtml-call "REQUEST.set('catlist',[])"> <dtml-in CategorySelectQuery start=query_start> <option><dtml-var category> <dtml-call "catlist.append(category))"> </dtml-in> </select> Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Timothy Grant" <tjg@avalongroup.net> To: "Zope Folk" <zope@zope.org> Sent: Monday, January 03, 2000 12:34 PM Subject: [Zope] Creating a List from a SQLMethod
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?
Thanks.
-- Stand Fast, tjg.
Chief Technology Officer tjg@exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. (503) 246-3630
>>>>>>>EXCEPTIONAL MINDS, INNOVATIVE PRODUCTS<<<<<<<<<<<<
_______________________________________________ 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 )
If you have cacheing turned on for the query (cache persistence time > time for zope to render page), zope should pull the select items from the cache and not actually rerun the query on the database server. Therefore, the time saved by creating a list to reuse is probably negligible. Also, the way you are doing it results in the list of select items being sent in html multiple times, if the select is a long one this will noticebly slow down the loading speed on the browser for those with slow connections. An alternative would be to create a javascript array once and use a javascript function to create the select lists on the browser to your hearts content. __________________________________________________________________ Jim Sanford . Database/Web Engineer / \ / Accelerated Technology, Inc. / / 720 Oak Circle Drive East / / \ Mobile, AL 36609 / / \ Voice: 334-661-5770 fax: 334-661-5788 / \ E-Mail: jsanford@atinucleus.com Web: http://www.atinucleus.com Source Code, No Royalties, Any CPU...It just make sense ! __________________________________________________________________ ----- Original Message ----- From: Phil Harris <phil.harris@zope.co.uk> To: Timothy Grant <tjg@avalongroup.net>; Zope Folk <zope@zope.org> Sent: Monday, January 03, 2000 5:10 PM Subject: Re: [Zope] Creating a List from a SQLMethod How about something like (untested) <select name="Category"> <option>(None)> <dtml-call "REQUEST.set('catlist',[])"> <dtml-in CategorySelectQuery start=query_start> <option><dtml-var category> <dtml-call "catlist.append(category))"> </dtml-in> </select> Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Timothy Grant" <tjg@avalongroup.net> To: "Zope Folk" <zope@zope.org> Sent: Monday, January 03, 2000 12:34 PM Subject: [Zope] Creating a List from a SQLMethod
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?
Thanks.
-- Stand Fast, tjg.
Chief Technology Officer tjg@exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. (503) 246-3630
>>>>>>>EXCEPTIONAL MINDS, INNOVATIVE PRODUCTS<<<<<<<<<<<<
_______________________________________________ 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 )
_______________________________________________ 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 )
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.
participants (4)
-
Jim Fulton -
Jim Sanford -
Phil Harris -
Timothy Grant