Added new base interface for shared contents implementing portal context
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Jun 2018 16:48:57 +0200
changeset 621 a75b1fc09fde
parent 620 7de4aaf90bff
child 622 76b7c0b5bfa6
Added new base interface for shared contents implementing portal context
src/pyams_content/shared/blog/__init__.py
src/pyams_content/shared/blog/interfaces/__init__.py
src/pyams_content/shared/common/interfaces/__init__.py
src/pyams_content/shared/form/__init__.py
src/pyams_content/shared/form/interfaces/__init__.py
src/pyams_content/shared/news/__init__.py
src/pyams_content/shared/news/interfaces/__init__.py
src/pyams_content/shared/site/__init__.py
src/pyams_content/shared/site/interfaces/__init__.py
--- a/src/pyams_content/shared/blog/__init__.py	Mon Jun 11 16:13:17 2018 +0200
+++ b/src/pyams_content/shared/blog/__init__.py	Mon Jun 11 16:48:57 2018 +0200
@@ -23,18 +23,16 @@
 from pyams_content.features.review.interfaces import IReviewTarget
 from pyams_content.shared.blog.interfaces import IWfBlogPost, BLOG_CONTENT_TYPE, BLOG_CONTENT_NAME, IBlogPost, \
     IWfBlogPostFactory
-from pyams_portal.interfaces import IPortalContext, IPortalPage, PORTAL_PAGE_KEY
 from pyams_workflow.interfaces import IWorkflow, IWorkflowVersions, IWorkflowState
 
 # import packages
 from pyams_content.shared.common import WfSharedContent, register_content_type, SharedContent, IWfSharedContentFactory
-from pyams_content.shared.common.portal import SharedContentPortalPage
-from pyams_utils.adapter import adapter_config, get_annotation_adapter
+from pyams_utils.adapter import adapter_config
 from zope.interface import implementer, provider
 
 
 @implementer(IWfBlogPost, IParagraphContainerTarget, IThemesTarget, IIllustrationTarget,
-             IPortalContext, IPreviewTarget, IReviewTarget)
+             IPreviewTarget, IReviewTarget)
 class WfBlogPost(WfSharedContent):
     """Base blog post"""
 
@@ -60,9 +58,3 @@
 @adapter_config(context=IWfBlogPostFactory, provides=IWfSharedContentFactory)
 def blog_post_content_factory(context):
     return WfBlogPost
-
-
-@adapter_config(context=IWfBlogPost, provides=IPortalPage)
-def blog_post_portal_page_adapter(context):
-    """Blog post portal page adapter"""
-    return get_annotation_adapter(context, PORTAL_PAGE_KEY, SharedContentPortalPage)
--- a/src/pyams_content/shared/blog/interfaces/__init__.py	Mon Jun 11 16:13:17 2018 +0200
+++ b/src/pyams_content/shared/blog/interfaces/__init__.py	Mon Jun 11 16:48:57 2018 +0200
@@ -16,8 +16,8 @@
 # import standard library
 
 # import interfaces
-from pyams_content.shared.common.interfaces import ISharedSite, IBaseSharedTool, IWfSharedContent, ISharedContent, \
-    IDeletableElement
+from pyams_content.shared.common.interfaces import ISharedSite, IBaseSharedTool, ISharedContent, \
+    IDeletableElement, IWfSharedContentPortalContext
 from pyams_sequence.interfaces import ISequentialIdTarget
 from pyams_workflow.interfaces import IWorkflowPublicationSupport
 from zope.container.interfaces import IContainer
@@ -33,7 +33,7 @@
 BLOG_CONTENT_NAME = _("Blog post")
 
 
-class IWfBlogPost(IWfSharedContent):
+class IWfBlogPost(IWfSharedContentPortalContext):
     """Blog topic interface"""
 
 
--- a/src/pyams_content/shared/common/interfaces/__init__.py	Mon Jun 11 16:13:17 2018 +0200
+++ b/src/pyams_content/shared/common/interfaces/__init__.py	Mon Jun 11 16:48:57 2018 +0200
@@ -9,6 +9,7 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyams_portal.interfaces import IPortalContext
 
 __docformat__ = 'restructuredtext'
 
@@ -156,6 +157,10 @@
                    required=False)
 
 
+class IWfSharedContentPortalContext(IWfSharedContent, IPortalContext):
+    """Shared content with portal support"""
+
+
 class IWfSharedContentFactory(Interface):
     """Shared content factory interface"""
 
--- a/src/pyams_content/shared/form/__init__.py	Mon Jun 11 16:13:17 2018 +0200
+++ b/src/pyams_content/shared/form/__init__.py	Mon Jun 11 16:48:57 2018 +0200
@@ -21,13 +21,11 @@
 from pyams_content.features.review.interfaces import IReviewTarget
 from pyams_content.shared.form.interfaces import IWfForm, IForm, FORM_CONTENT_TYPE, FORM_CONTENT_NAME, \
     IFormFieldContainerTarget, IFormHandler, IFormFieldContainer, IWfFormFactory
-from pyams_portal.interfaces import IPortalPage, PORTAL_PAGE_KEY, IPortalContext
 
 # import packages
 from pyams_content.shared.common import WfSharedContent, SharedContent, register_content_type, WfSharedContentChecker, \
     IWfSharedContentFactory
-from pyams_content.shared.common.portal import SharedContentPortalPage
-from pyams_utils.adapter import adapter_config, get_annotation_adapter
+from pyams_utils.adapter import adapter_config
 from pyams_utils.registry import get_global_registry
 from zope.interface import implementer, provider, alsoProvides, noLongerProvides
 from zope.schema.fieldproperty import FieldProperty
@@ -36,7 +34,7 @@
 
 
 @implementer(IWfForm, IFormFieldContainerTarget,
-             IPortalContext, IPreviewTarget, IReviewTarget)
+             IPreviewTarget, IReviewTarget)
 class WfForm(WfSharedContent):
     """Base form"""
 
@@ -90,12 +88,6 @@
     return WfForm
 
 
-@adapter_config(context=IWfForm, provides=IPortalPage)
-def form_portal_page_adapter(context):
-    """Form portal page adapter"""
-    return get_annotation_adapter(context, PORTAL_PAGE_KEY, SharedContentPortalPage)
-
-
 @adapter_config(name='properties', context=IWfForm, provides=IContentChecker)
 class WfFormContentChecker(WfSharedContentChecker):
     """Form content checker"""
--- a/src/pyams_content/shared/form/interfaces/__init__.py	Mon Jun 11 16:13:17 2018 +0200
+++ b/src/pyams_content/shared/form/interfaces/__init__.py	Mon Jun 11 16:48:57 2018 +0200
@@ -16,7 +16,7 @@
 # import standard library
 
 # import interfaces
-from pyams_content.shared.common.interfaces import ISharedTool, IWfSharedContent, ISharedContent
+from pyams_content.shared.common.interfaces import ISharedTool, ISharedContent, IWfSharedContentPortalContext
 from zope.annotation.interfaces import IAttributeAnnotatable
 from zope.container.interfaces import IContainer, IContained
 
@@ -115,7 +115,7 @@
     """Form fields container target marker interface"""
 
 
-class IWfForm(IWfSharedContent):
+class IWfForm(IWfSharedContentPortalContext):
     """Form interface"""
 
     user_title = I18nTextLineField(title=_("Form title"),
--- a/src/pyams_content/shared/news/__init__.py	Mon Jun 11 16:13:17 2018 +0200
+++ b/src/pyams_content/shared/news/__init__.py	Mon Jun 11 16:48:57 2018 +0200
@@ -23,17 +23,15 @@
 from pyams_content.features.review.interfaces import IReviewTarget
 from pyams_content.shared.news.interfaces import INewsEvent, IWfNewsEvent, NEWS_CONTENT_TYPE, NEWS_CONTENT_NAME, \
     IWfNewsEventFactory
-from pyams_portal.interfaces import IPortalContext, IPortalPage, PORTAL_PAGE_KEY
 
 # import packages
 from pyams_content.shared.common import SharedContent, WfSharedContent, register_content_type, IWfSharedContentFactory
-from pyams_content.shared.common.portal import SharedContentPortalPage
-from pyams_utils.adapter import adapter_config, get_annotation_adapter
+from pyams_utils.adapter import adapter_config
 from zope.interface import implementer, provider
 
 
 @implementer(IWfNewsEvent, IIllustrationTarget, IParagraphContainerTarget, IThemesTarget,
-             IPortalContext, IPreviewTarget, IReviewTarget)
+             IPreviewTarget, IReviewTarget)
 class WfNewsEvent(WfSharedContent):
     """Base news event"""
 
@@ -52,9 +50,3 @@
 @adapter_config(context=IWfNewsEventFactory, provides=IWfSharedContentFactory)
 def news_event_content_factory(context):
     return WfNewsEvent
-
-
-@adapter_config(context=IWfNewsEvent, provides=IPortalPage)
-def news_event_portal_page_adapter(context):
-    """News event portal page adapter"""
-    return get_annotation_adapter(context, PORTAL_PAGE_KEY, SharedContentPortalPage)
--- a/src/pyams_content/shared/news/interfaces/__init__.py	Mon Jun 11 16:13:17 2018 +0200
+++ b/src/pyams_content/shared/news/interfaces/__init__.py	Mon Jun 11 16:48:57 2018 +0200
@@ -16,7 +16,8 @@
 # import standard library
 
 # import interfaces
-from pyams_content.shared.common.interfaces import ISharedTool, IWfSharedContent, ISharedContent
+from pyams_content.shared.common.interfaces import ISharedTool, ISharedContent, \
+    IWfSharedContentPortalContext
 
 # import packages
 from zope.interface import Interface
@@ -36,7 +37,7 @@
     """News manager factory interface"""
 
 
-class IWfNewsEvent(IWfSharedContent):
+class IWfNewsEvent(IWfSharedContentPortalContext):
     """News event interface"""
 
 
--- a/src/pyams_content/shared/site/__init__.py	Mon Jun 11 16:13:17 2018 +0200
+++ b/src/pyams_content/shared/site/__init__.py	Mon Jun 11 16:48:57 2018 +0200
@@ -23,18 +23,16 @@
 from pyams_content.features.review.interfaces import IReviewTarget
 from pyams_content.shared.site.interfaces import ITopic, IWfTopic, TOPIC_CONTENT_NAME, \
     TOPIC_CONTENT_TYPE, IWfTopicFactory
-from pyams_portal.interfaces import IPortalContext, IPortalPage, PORTAL_PAGE_KEY
 from pyams_workflow.interfaces import IWorkflow, IWorkflowVersions, IWorkflowState
 
 # import packages
 from pyams_content.shared.common import SharedContent, WfSharedContent, register_content_type, IWfSharedContentFactory
-from pyams_content.shared.common.portal import SharedContentPortalPage
-from pyams_utils.adapter import adapter_config, get_annotation_adapter
+from pyams_utils.adapter import adapter_config
 from zope.interface import implementer, provider
 
 
-@implementer(IWfTopic, IParagraphContainerTarget, IThemesTarget, IIllustrationTarget,
-             IPortalContext, IPreviewTarget, IReviewTarget)
+@implementer(IWfTopic, IIllustrationTarget, IParagraphContainerTarget, IThemesTarget,
+             IPreviewTarget, IReviewTarget)
 class WfTopic(WfSharedContent):
     """Base topic"""
 
@@ -62,9 +60,3 @@
 @adapter_config(context=IWfTopicFactory, provides=IWfSharedContentFactory)
 def topic_content_factory(context):
     return WfTopic
-
-
-@adapter_config(context=IWfTopic, provides=IPortalPage)
-def topic_portal_page_adapter(context):
-    """Topic portal page adapter"""
-    return get_annotation_adapter(context, PORTAL_PAGE_KEY, SharedContentPortalPage)
--- a/src/pyams_content/shared/site/interfaces/__init__.py	Mon Jun 11 16:13:17 2018 +0200
+++ b/src/pyams_content/shared/site/interfaces/__init__.py	Mon Jun 11 16:48:57 2018 +0200
@@ -22,8 +22,8 @@
 from zope.container.interfaces import IContainer, IContained
 
 # import packages
-from pyams_content.shared.common.interfaces import ISharedSite, IWfSharedContent, ISharedContent, \
-    IBaseContentManagerRoles, IBaseSharedTool, IDeletableElement
+from pyams_content.shared.common.interfaces import ISharedSite, ISharedContent, \
+    IBaseContentManagerRoles, IBaseSharedTool, IDeletableElement, IWfSharedContentPortalContext
 from pyams_i18n.schema import I18nTextLineField, I18nTextField
 from zope.container.constraints import containers, contains
 from zope.interface import Interface, Attribute
@@ -95,7 +95,7 @@
 TOPIC_CONTENT_NAME = _("Topic")
 
 
-class IWfTopic(IWfSharedContent):
+class IWfTopic(IWfSharedContentPortalContext):
     """Topic interface"""