def render(self):
        # set up a reference to the original template
        filename = pkg_resources.resource_filename(pkg_resources.Requirement.parse('plone.app.layout'), 'plone/app/layout/viewlets/contentviews.pt')
        self.template_file = ViewPageTemplateFile(filename)

        # if we're looking at a mailing list, then show that immediately
        if IMailingList.providedBy(self.context):
            # Remove the disable border setting if it's set
            # or we won't get the proper content views on archives or posts
            try:
                del self.request.other['disable_border']
            except KeyError:
                pass
            # and always enable it
            self.request.other['enable_border'] = True
            return self.template_file()

        # otherwise, check if we have a mailing list in the parents
        for obj in aq_chain(aq_inner(self.context)):
            if IMailingList.providedBy(obj):
                # show the content views in the mailing list's context
                viewlet = getMultiAdapter((obj,
                                           self.request,
                                           self.__parent__,
                                           self.manager),
                                          name='plone.contentviews')
                viewlet.update()
                return viewlet.render()

        # we didn't have a mailing list in our chain, so return the default
        return self.template_file()
示例#2
0
    def render(self):
        # set up a reference to the original template
        filename = pkg_resources.resource_filename(
            pkg_resources.Requirement.parse('plone.app.layout'),
            'plone/app/layout/viewlets/contentviews.pt')
        self.template_file = ViewPageTemplateFile(filename)

        # if we're looking at a mailing list, then show that immediately
        if IMailingList.providedBy(self.context):
            # Remove the disable border setting if it's set
            # or we won't get the proper content views on archives or posts
            try:
                del self.request.other['disable_border']
            except KeyError:
                pass
            # and always enable it
            self.request.other['enable_border'] = True
            return self.template_file()

        # otherwise, check if we have a mailing list in the parents
        for obj in aq_chain(aq_inner(self.context)):
            if IMailingList.providedBy(obj):
                # show the content views in the mailing list's context
                viewlet = getMultiAdapter(
                    (obj, self.request, self.__parent__, self.manager),
                    name='plone.contentviews')
                viewlet.update()
                return viewlet.render()

        # we didn't have a mailing list in our chain, so return the default
        return self.template_file()
示例#3
0
 def getMailingList(self):
     if self._mailing_list is None:
         # climb aq chain to get the mailing list object
         for parent in aq_chain(aq_inner(self.context)):
             if IMailingList.providedBy(parent):
                 self._mailing_list = [aq_inner(parent)]
                 break
     return self._mailing_list[0]
 def getMailingList(self):
     if self._mailing_list is None:
         # climb aq chain to get the mailing list object
         for parent in aq_chain(aq_inner(self.context)):
             if IMailingList.providedBy(parent):
                 self._mailing_list = [aq_inner(parent)]
                 break
     return self._mailing_list[0]
示例#5
0
 def num_lists(self):
     container = self.listen_container()
     obs = container.objectValues()
     num_lists = len([ob for ob in obs if IMailingList.providedBy(ob)])
     return num_lists