Exemplo n.º 1
0
    def __call__(self):
        """Return the rendered contents of the viewlet manager specified."""
        manager = self.data.get('manager')
        viewName = self.data.get('view', None)
        section = self.data.get('section', 'body')
        viewlet = self.data.get('viewlet', None)

        view = findView(self, viewName)

        if not IFolderish.providedBy(self.context):
            self.context = self.context.aq_parent

        managerObj = queryMultiAdapter(
            (self.context, self.request, view),
            IViewletManager,
            name=manager
        )
        managerObj.update()

        obj_to_render = managerObj

        if viewlet:
            provided_viewlets = [i.__name__ for i in managerObj.viewlets]
            if viewlet not in provided_viewlets:
                mgr_name = managerObj.__name__
                msg = 'Viewlet %s is not provided by %s' % (viewlet,
                                                            mgr_name)
                raise ValueError(msg)
            obj_to_render = [i for i in managerObj.viewlets
                             if i.__name__ == viewlet][0]

        if section == 'head':
            return u"<html><head>%s</head></html>" % obj_to_render.render()
        else:
            return u"<html><body>%s</body></html>" % obj_to_render.render()
Exemplo n.º 2
0
    def __call__(self):
        """Return the rendered contents of the viewlet manager specified."""
        manager = self.data.get('manager')
        viewName = self.data.get('view', None)
        section = self.data.get('section', 'body')
        viewlet = self.data.get('viewlet', None)

        view = findView(self, viewName)

        managerObj = queryMultiAdapter((self.context, self.request, view),
                                       IViewletManager,
                                       name=manager)
        managerObj.update()

        obj_to_render = managerObj

        if viewlet:
            provided_viewlets = [i.__name__ for i in managerObj.viewlets]
            if viewlet not in provided_viewlets:
                mgr_name = managerObj.__name__
                msg = 'Viewlet %s is not provided by %s' % (viewlet, mgr_name)
                raise ValueError(msg)
            obj_to_render = [
                i for i in managerObj.viewlets if i.__name__ == viewlet
            ][0]

        if section == 'head':
            return u"<html><head>%s</head></html>" % obj_to_render.render()
        else:
            return u"<html><body>%s</body></html>" % obj_to_render.render()
    def __call__(self):
        """Return the rendered contents of the portlet manager specified."""
        manager = self.data.get('manager')
        viewName = self.data.get('view')
        managerObj = queryUtility(IPortletManager, name=manager)
        if managerObj is None:
            return u'<html><body></body></html>'
        view = findView(self, viewName)

        # set redirection view
        self.request['viewname'] = '@@manage-portlets'
        rendererObj = managerObj(self.context, self.request, view)
        rendererObj.update()

        return u'<html><body>{0:s}</body></html>'.format(rendererObj.render())
    def __call__(self):
        """Return the rendered contents of the portlet manager specified."""
        manager = self.data.get('manager')
        viewName = self.data.get('view')
        managerObj = queryUtility(IPortletManager, name=manager)
        if managerObj is None:
            return u'<html><body></body></html>'
        view = findView(self, viewName)

        # set redirection view
        self.request['viewname'] = '@@manage-portlets'
        rendererObj = managerObj(self.context, self.request, view)
        rendererObj.update()

        return u'<html><body>{0:s}</body></html>'.format(rendererObj.render())