Back to index

plone3  3.1.7
RSS.py
Go to the documentation of this file.
00001 ##parameters=
00002 ##
00003 from ZTUtils import Batch
00004 from ZTUtils import LazyFilter
00005 from Products.CMFCore.utils import getUtilityByInterfaceName
00006 from Products.CMFDefault.utils import decode
00007 
00008 stool = getUtilityByInterfaceName('Products.CMFCore.interfaces.ISyndicationTool')
00009 
00010 
00011 if not stool.isSyndicationAllowed(context):
00012     context.REQUEST.RESPONSE.redirect(context.absolute_url() +
00013              '/rssDisabled?portal_status_message=Syndication+is+Disabled')
00014     return
00015 
00016 
00017 options = {}
00018 
00019 options['channel_info'] = { 'base': stool.getHTML4UpdateBase(context),
00020                             'description': context.Description(),
00021                             'frequency': stool.getUpdateFrequency(context),
00022                             'period': stool.getUpdatePeriod(context),
00023                             'title': context.Title(),
00024                             'url': context.absolute_url() }
00025 
00026 key, reverse = context.getDefaultSorting()
00027 items = stool.getSyndicatableContent(context)
00028 items = sequence.sort( items, ((key, 'cmp', reverse and 'desc' or 'asc'),) )
00029 items = LazyFilter(items, skip='View')
00030 b_size = stool.getMaxItems(context)
00031 batch_obj = Batch(items, b_size, 0, orphan=0)
00032 items = []
00033 for item in batch_obj:
00034     items.append( { 'date': item.modified().HTML4(),
00035                     'description': item.Description(),
00036                     'listCreators': item.listCreators(),
00037                     'listSubjects': item.Subject(),
00038                     'publisher': item.Publisher(),
00039                     'rights': item.Rights(),
00040                     'title': item.Title(),
00041                     'url': item.absolute_url() } )
00042 options['listItemInfos'] = tuple(items)
00043 
00044 return context.RSS_template(**decode(options, script))