Back to index

plone3  3.1.7
recent_news.py
Go to the documentation of this file.
00001 ##parameters=b_start=0
00002 ##
00003 from Products.PythonScripts.standard import structured_text
00004 from ZTUtils import Batch
00005 from Products.CMFCore.utils import getToolByName
00006 from Products.CMFDefault.utils import decode
00007 
00008 ctool = getToolByName(script, 'portal_catalog')
00009 utool = getToolByName(script, 'portal_url')
00010 portal_url = utool()
00011 
00012 
00013 options = {}
00014 
00015 target = '%s/recent_news' % portal_url
00016 items = ctool.searchResults(portal_type='News Item', sort_on='Date',
00017                             sort_order='reverse', review_state='published')
00018 batch_obj = Batch(items, 10, b_start, orphan=1)
00019 
00020 items = [ {'creators': item.listCreators,
00021            'date': item.Date,
00022            'description': structured_text(item.Description),
00023            'title': item.Title,
00024            'url': item.getURL()}
00025           for item in batch_obj ]
00026 
00027 navigation = context.getBatchNavigation(batch_obj, target)
00028 options['batch'] = {'listItemInfos': items,
00029                     'navigation': navigation}
00030 
00031 return context.recent_news_template(**decode(options, script))