Check context before extracting content type
authorThierry Florac <thierry.florac@onf.fr>
Fri, 26 Oct 2018 09:00:07 +0200
changeset 1041 e22f30b4ef3a
parent 1040 d2485124991c
child 1042 375c07107cf2
Check context before extracting content type
src/pyams_content/shared/view/__init__.py
--- a/src/pyams_content/shared/view/__init__.py	Fri Oct 26 08:59:12 2018 +0200
+++ b/src/pyams_content/shared/view/__init__.py	Fri Oct 26 09:00:07 2018 +0200
@@ -32,7 +32,8 @@
 from pyams_catalog.query import CatalogResultSet, or_
 from pyams_content.features.preview.interfaces import IPreviewTarget
 from pyams_content.features.review.interfaces import IReviewTarget
-from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent, IWfSharedContentFactory
+from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent, IWfSharedContentFactory, \
+    IWfSharedContent
 from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
 from pyams_content.shared.view.interfaces import IView, IWfView, IWfViewFactory, IViewQuery, \
     IViewQueryParamsExtension, IViewQueryFilterExtension, VIEW_CONTENT_TYPE, VIEW_CONTENT_NAME, IViewSettings
@@ -86,7 +87,7 @@
 
     def get_content_types(self, context):
         content_types = set()
-        if self.select_context_type:
+        if self.select_context_type and IWfSharedContent.providedBy(context):
             content_types.add(context.content_type)
         if self.selected_content_types:
             content_types |= set(self.selected_content_types)