Always use merge event if a single view is selected
authorThierry Florac <thierry.florac@onf.fr>
Thu, 05 Jul 2018 08:48:47 +0200
changeset 799 dd66696cb871
parent 798 754dcbb0ede9
child 800 2b5460ecb254
Always use merge event if a single view is selected
src/pyams_content/shared/view/portlet/__init__.py
--- a/src/pyams_content/shared/view/portlet/__init__.py	Wed Jul 04 17:17:57 2018 +0200
+++ b/src/pyams_content/shared/view/portlet/__init__.py	Thu Jul 05 08:48:47 2018 +0200
@@ -9,7 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from pyams_portal.interfaces import PREVIEW_MODE
 
 __docformat__ = 'restructuredtext'
 
@@ -20,6 +19,7 @@
 # import interfaces
 from pyams_content.shared.view.interfaces import IViewsMerger
 from pyams_content.shared.view.portlet.interfaces import IViewItemsPortletSettings, VIEW_DISPLAY_CONTEXT
+from pyams_portal.interfaces import PREVIEW_MODE
 from pyams_utils.interfaces import VIEW_PERMISSION
 from pyams_utils.interfaces.url import DISPLAY_CONTEXT
 
@@ -69,18 +69,12 @@
             context = request.context
         if not ignore_cache:
             ignore_cache = request.annotations.get(PREVIEW_MODE, False)
-        if len(self.views or ()) < 2:  # single view
-            for view in self.get_views():
-                if view is not None:
-                    yield from islice(view.get_results(context, ignore_cache=ignore_cache),
-                                      self.limit)
-        else:  # several views merged together
-            merger = self.get_merger(request)
-            if merger is not None:
-                yield from islice(unique_iter(merger.get_results(self.get_views(),
-                                                                 context,
-                                                                 ignore_cache=ignore_cache)),
-                                  self.limit)
+        merger = self.get_merger(request)
+        if merger is not None:
+            yield from islice(unique_iter(merger.get_results(self.get_views(),
+                                                             context,
+                                                             ignore_cache=ignore_cache)),
+                              self.limit)
 
 
 @portlet_config(permission=VIEW_PERMISSION)