I have some data returned by a SQL Method that I want to randomly pick from. Since I cannot get the SQL Statement to return random data sets I was going to use the "_.whrandom.choice" to go over the SQL list and create a new list of the randomized choices. This will go over the SQL Content <dtml-in sqlMethod size=10 start=query_start> </dtml-in> But how do I create a list? (in Python I would just say list = () and a list.append() TIA, JMA
"J. Atwood" wrote:
I have some data returned by a SQL Method that I want to randomly pick from. Since I cannot get the SQL Statement to return random data sets I was going to use the "_.whrandom.choice" to go over the SQL list and create a new list of the randomized choices.
This will go over the SQL Content <dtml-in sqlMethod size=10 start=query_start> </dtml-in>
But how do I create a list? (in Python I would just say list = () and a list.append()
Are you just afeter a single random item from a ZSQL query? If so: <dtml-with "_.whrandom.choice(_['getcategories'])"> <dtml-var category> </dtml-with> Works for me. In this case, 'getcategories' is a ZSQL method that returns a list of categories, consisting of: "select category from linkCategories" Bill -- In flying I have learned that carelessness and overconfidence are usually far more dangerous than deliberately accepted risks. -- Wilbur Wright in a letter to his father, September 1900
Hi Bill, This will return one of the the data elements and it does work. I am trying to build a list of random elements from the sql data. JMA
From: Bill Anderson <bill@libc.org> Organization: Linux in Boise Club Date: Wed, 15 Mar 2000 22:01:54 -0700 To: zope@zope.org Subject: Re: [Zope] Randomizing SQL Data ?
"J. Atwood" wrote:
I have some data returned by a SQL Method that I want to randomly pick from. Since I cannot get the SQL Statement to return random data sets I was going to use the "_.whrandom.choice" to go over the SQL list and create a new list of the randomized choices.
This will go over the SQL Content <dtml-in sqlMethod size=10 start=query_start> </dtml-in>
But how do I create a list? (in Python I would just say list = () and a list.append()
Are you just afeter a single random item from a ZSQL query? If so:
<dtml-with "_.whrandom.choice(_['getcategories'])"> <dtml-var category> </dtml-with>
Works for me. In this case, 'getcategories' is a ZSQL method that returns a list of categories, consisting of: "select category from linkCategories"
Bill -- In flying I have learned that carelessness and overconfidence are usually far more dangerous than deliberately accepted risks. -- Wilbur Wright in a letter to his father, September 1900
_______________________________________________ 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 )
participants (2)
-
Bill Anderson -
J. Atwood