source: products/quintagroup.plonegooglesitemaps/branches/configurable_types_extending/quintagroup/plonegooglesitemaps/browser/newssitemapview.py

Last change on this file was 2399, checked in by mylan, 14 years ago

#131: code cleanup

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1import re
2from DateTime import DateTime
3from commonview import *
4from zope.component import getMultiAdapter
5
6reTrailingParenthtical = re.compile("\s*\(.*\)\s*", re.S)
7
8class NewsSitemapView(CommonSitemapView):
9    """
10    News Sitemap browser view
11    """
12    implements(ISitemapView)
13
14    additional_maps = (
15        ('publication_date', lambda x:DateTime(x.EffectiveDate).strftime("%Y-%m-%d")),
16        ('keywords', lambda x:', '.join(x.Subject)),
17        ('title', lambda x:x.Title),
18        ('name', lambda x:reTrailingParenthtical.sub("",x.Title)),
19        ('language', lambda x:x.Language),
20        ('access', lambda x:x.gsm_access),
21        ('genres', lambda x:x.gsm_genres),
22    )
23
24    def getFilteredObjects(self):
25        path = self.portal.getPhysicalPath()
26        portal_types = self.context.getPortalTypes()
27        review_states = self.context.getStates()
28        min_date = DateTime() - 3
29        res = self.portal_catalog(path = path,
30                portal_type = portal_types,
31                review_state = review_states,
32                effective = {"query": min_date,
33                             "range": "min" })
34        return res
Note: See TracBrowser for help on using the repository browser.