Added custom shared content portal page adapter
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Jun 2018 15:00:12 +0200
changeset 614 0b5ec468c64b
parent 613 cf14f3928a90
child 615 75625e045aef
Added custom shared content portal page adapter
src/pyams_content/shared/common/portal.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/common/portal.py	Mon Jun 11 15:00:12 2018 +0200
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_content.shared.common.interfaces import IBaseSharedTool
+from pyams_portal.interfaces import IPortalPage
+
+# import packages
+from pyams_portal.page import PortalPage
+from pyams_utils.traversing import get_parent
+
+
+class SharedContentPortalPage(PortalPage):
+    """Shared content portal page"""
+
+    @property
+    def can_inherit(self):
+        return IPortalPage(self.parent).template is not None
+
+    @property
+    def parent(self):
+        return get_parent(self, IBaseSharedTool, allow_context=False)