1 | from zope.interface import implements |
---|
2 | |
---|
3 | from quills.core.interfaces import IWeblogEntry |
---|
4 | from quills.core.interfaces.enabled import IPossibleWeblogEntry |
---|
5 | from quills.app.utilities import getArchivePathFor, getArchivePathFor |
---|
6 | |
---|
7 | from Products.CMFCore.utils import getToolByName |
---|
8 | |
---|
9 | from Products.fatsyndication.adapters.feedentry import DocumentFeedEntry as BaseFeedEntry |
---|
10 | |
---|
11 | class quillsCanonicalPathAdapter(object): |
---|
12 | """Adapts quills entry content to canonical path. |
---|
13 | """ |
---|
14 | def __init__(self, context): |
---|
15 | self.context = context |
---|
16 | |
---|
17 | def canonical_path(self): |
---|
18 | purl = getToolByName(self.context,'portal_url') |
---|
19 | pw = getToolByName(self.context,'portal_workflow') |
---|
20 | relpath = '/' + purl.getRelativeContentURL(self.context) |
---|
21 | if pw.getInfoFor(self.context, 'review_state') == 'published': |
---|
22 | entry = IWeblogEntry(self.context).__of__(self.context.aq_inner.aq_parent) |
---|
23 | weblog_content = entry.getWeblogContentObject() |
---|
24 | if weblog_content is not None: |
---|
25 | weblog_path = '/' + purl.getRelativeContentURL(weblog_content) |
---|
26 | relpath = '%s/%s' % (weblog_path,'/'.join(getArchivePathFor(entry, weblog_content))) |
---|
27 | return relpath |
---|
28 | |
---|
29 | |
---|
30 | class DocumentFeedEntry(BaseFeedEntry): |
---|
31 | """ Fix effective date. |
---|
32 | BaseFeedEntry overwrite return modification date for |
---|
33 | getEffectiveDate method. This lead to change entries |
---|
34 | order in result feed. |
---|
35 | """ |
---|
36 | |
---|
37 | def getEffectiveDate(self): |
---|
38 | """See IFeedEntry. |
---|
39 | """ |
---|
40 | return self.context.effective() |
---|