[Zope-CMF] Random Results from portal_catalog in ZPT
Dieter Maurer
dieter@handshake.de
Fri, 12 Apr 2002 21:56:27 +0200
Carl Rendell writes:
> Anyone have a standard way they obtain random content from a
> portal_catalog search in ZPT?
What a strange question. Usually, I want my search results be deterministic,
not random ;-)
Anyway. Catalog searches return sequences.
The "random" (maybe "whrandom") module contains a "choice" function
that allows you to randomly select an element from a sequence.
Both modules are directly available to both Python Scripts and ZPT.
Combine the above and you get a randomly selected catalog hit.
When you want more than one, repeat it in a script and append the
results.
Dieter