[2396] | 1 | import re |
---|
[1593] | 2 | from DateTime import DateTime |
---|
| 3 | from commonview import * |
---|
[2396] | 4 | from zope.component import getMultiAdapter |
---|
[1593] | 5 | |
---|
[2396] | 6 | reTrailingParenthtical = re.compile("\s*\(.*\)\s*", re.S) |
---|
| 7 | |
---|
[1593] | 8 | class NewsSitemapView(CommonSitemapView): |
---|
| 9 | """ |
---|
[2396] | 10 | News Sitemap browser view |
---|
[1593] | 11 | """ |
---|
| 12 | implements(ISitemapView) |
---|
| 13 | |
---|
| 14 | additional_maps = ( |
---|
[2396] | 15 | ('publication_date', lambda x:DateTime(x.EffectiveDate).strftime("%Y-%m-%d")), |
---|
| 16 | ('keywords', lambda x:', '.join(x.Subject)), |
---|
| 17 | ('name', lambda x:reTrailingParenthtical.sub("",x.Title)), |
---|
| 18 | ('title', lambda x:x.Title), |
---|
| 19 | ('language', lambda x:x.Language), |
---|
[1593] | 20 | ) |
---|
| 21 | |
---|
| 22 | def getFilteredObjects(self): |
---|
| 23 | path = self.portal.getPhysicalPath() |
---|
| 24 | portal_types = self.context.getPortalTypes() |
---|
| 25 | review_states = self.context.getStates() |
---|
| 26 | min_date = DateTime() - 3 |
---|
| 27 | res = self.portal_catalog(path = path, |
---|
| 28 | portal_type = portal_types, |
---|
| 29 | review_state = review_states, |
---|
| 30 | effective = {"query": min_date, |
---|
| 31 | "range": "min" }) |
---|
[2396] | 32 | return res |
---|