1 | import re |
---|
2 | from DateTime import DateTime |
---|
3 | from commonview import * |
---|
4 | from zope.component import getMultiAdapter |
---|
5 | |
---|
6 | reTrailingParenthtical = re.compile("\s*\(.*\)\s*", re.S) |
---|
7 | |
---|
8 | class 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 |
---|