src/pyams_content/shared/common/portlet/content/skin/__init__.py
changeset 930 814f7c5e04d1
parent 929 1440d627e103
child 934 437971f8a969
child 936 2b31cde8c028
equal deleted inserted replaced
929:1440d627e103 930:814f7c5e04d1
     1 #
       
     2 # Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from pyams_content.shared.common.portlet.content.interfaces import ISharedContentPortletSettings
       
    20 from pyams_content.features.renderer.interfaces import ISharedContentRenderer
       
    21 from pyams_portal.interfaces import IPortalContext, IPortletRenderer
       
    22 from pyams_skin.layer import IPyAMSLayer
       
    23 
       
    24 # import packages
       
    25 from pyams_portal.portlet import PortletRenderer
       
    26 from pyams_template.template import template_config
       
    27 from pyams_utils.adapter import adapter_config
       
    28 from zope.interface import Interface
       
    29 
       
    30 from pyams_content import _
       
    31 
       
    32 
       
    33 @adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, ISharedContentPortletSettings),
       
    34                 provides=IPortletRenderer)
       
    35 @template_config(template='templates/content.pt', layer=IPyAMSLayer)
       
    36 class SharedContentPortletRenderer(PortletRenderer):
       
    37     """Shared content portlet renderer"""
       
    38 
       
    39     label = _("Default content renderer")
       
    40 
       
    41     def __init__(self, context, request, view, settings):
       
    42         super(SharedContentPortletRenderer, self).__init__(context, request, view, settings)
       
    43         registry = self.request.registry
       
    44         self.renderers = [adapter for name, adapter in sorted(registry.getAdapters((self.context, self.request),
       
    45                                                                                    ISharedContentRenderer),
       
    46                                                               key=lambda x: x[1].weight)]
       
    47 
       
    48     def update(self):
       
    49         super(SharedContentPortletRenderer, self).update()
       
    50         [renderer.update() for renderer in self.renderers]