Re: [Plone Community] Ideas for showing collection items in random order?

As you already note you'd need to bypass batching. How I would implement this:

  1. Perform "normal" query, unbatched.
  2. Randomize full result list. Is going to impact performance since you need to unpack the whole result iterator.
  3. Wrap the randomized result in a memoize. Here you decide whether to differentiate by user and how long you cache, by the way you define the memoization cache key.
  4. Then wrap that memoized randomized result into a batcher.

So the whole question of "storing a random ordering" here is solved by memoize, and you can define arbitrary policies by including cookies or other request variables into the cache key of that memoizer.

Hope that makes any sense?

Guido Stevens | +31.43.3618933 | http://cosent.nl

s o c i a l k n o w l e d g e t e c h n o l o g y

1 Like