--- a/src/pyams_content/shared/view/merge.py Tue Jul 03 12:14:35 2018 +0200
+++ b/src/pyams_content/shared/view/merge.py Tue Jul 03 14:19:24 2018 +0200
@@ -9,6 +9,7 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
+from pyams_utils.list import random_iter
__docformat__ = 'restructuredtext'
@@ -64,6 +65,20 @@
yield from chain(*results)
+@utility_config(name='random', provides=IViewsMerger)
+class ViewsRandomMergeMode(object):
+ """Views random merge mode"""
+
+ label = _("Extract items randomly")
+
+ @classmethod
+ def get_results(cls, views, context):
+ results = (view.get_results(context) for view in views)
+ results = list(chain(*results))
+ shuffle(results)
+ yield from iter(results)
+
+
@utility_config(name='zip', provides=IViewsMerger)
class ViewsZipMergeMode(object):
"""Views zip merge mode"""