# HG changeset patch # User Thierry Florac # Date 1476194713 -7200 # Node ID e917d512adbf653b07fff461eee0682720c6db92 # Parent 7adb05065e32d9eae247d38fd84f38d9cb1244f8 Added default portal page template for PyAMS default theme diff -r 7adb05065e32 -r e917d512adbf src/pyams_portal/templates/pagelet.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_portal/templates/pagelet.pt Tue Oct 11 16:05:13 2016 +0200 @@ -0,0 +1,24 @@ +
+
+
+
+ +
+
+
+ Content +
+
+
+
+
+
+
+
diff -r 7adb05065e32 -r e917d512adbf src/pyams_portal/views.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_portal/views.py Tue Oct 11 16:05:13 2016 +0200 @@ -0,0 +1,57 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# 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_default_theme.layer import IPyAMSDefaultLayer +from pyams_portal.interfaces import IPortalContext, IPortalPage, IPortalTemplateConfiguration, \ + IPortalPortletsConfiguration, IPortletRenderer, IPortlet + +# import packages +from pyams_default_theme.page import BaseIndexPage +from pyams_pagelet.pagelet import pagelet_config +from pyams_template.template import template_config +from pyramid.decorator import reify + + +@pagelet_config(name='', context=IPortalContext, layer=IPyAMSDefaultLayer) +@template_config(template='templates/pagelet.pt', layer=IPyAMSDefaultLayer) +class PortalContextIndexPage(BaseIndexPage): + """Portal context index page""" + + @reify + def page(self): + return IPortalPage(self.context) + + @reify + def template_configuration(self): + return IPortalTemplateConfiguration(self.page.template) + + @reify + def portlet_configuration(self): + return IPortalPortletsConfiguration(self.context) + + def get_portlet(self, name): + return self.request.registry.getUtility(IPortlet, name=name) + + def render_portlet(self, portlet_id): + settings = self.portlet_configuration.get_portlet_configuration(portlet_id).settings + renderer = self.request.registry.queryMultiAdapter((self.context, self.request, self, settings), + IPortletRenderer) + if renderer is not None: + return renderer() + else: + return ''