Back to index

plone3  3.1.7
news.py
Go to the documentation of this file.
00001 from Acquisition import aq_inner
00002 import zope.deprecation
00003 from zope.interface import implements
00004 
00005 from Products.Five import BrowserView
00006 from Products.CMFCore.utils import getToolByName
00007 from Products.CMFPlone.browser.interfaces import INewsPortlet
00008 
00009 
00010 class NewsPortlet(BrowserView):
00011     implements(INewsPortlet)
00012 
00013     def published_news_items(self):
00014         context = aq_inner(self.context)
00015         portal_catalog = getToolByName(context, 'portal_catalog')
00016 
00017         return self.request.get('news', 
00018                                 portal_catalog.searchResults(portal_type='News Item',
00019                                                              sort_on='Date',
00020                                                              sort_order='reverse',
00021                                                              review_state='published'))
00022     def all_news_link(self):
00023         context = aq_inner(self.context)
00024         utool = getToolByName(context, 'portal_url')
00025         portal_url = utool()
00026         portal = utool.getPortalObject()
00027 
00028         if 'news' in portal.objectIds():
00029             return '%s/news' % portal_url
00030         else:
00031             return '%s/news_listing' % portal_url
00032 
00033 zope.deprecation.deprecated(
00034   ('NewsPortlet', ),
00035    "Plone's portlets are based on plone.app.portlets now. The old portlets "
00036    "will be removed in Plone 4.0."
00037   )