[Zope] Randomizing SQL Data ?

Bill Anderson bill@libc.org
Wed, 15 Mar 2000 22:01:54 -0700


"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