source: products/quintagroup.quills.extras/trunk/quintagroup/quills/extras/adapters.py @ 1257

Last change on this file since 1257 was 1245, checked in by mylan, 15 years ago

Fix bug in canonical path adapter for IPossibleWeblogEntry (Document in case of QuillsEnabled?)

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1from zope.interface import implements
2
3from quills.core.interfaces import IWeblogEntry
4from quills.core.interfaces.enabled import IPossibleWeblogEntry
5from quills.app.utilities import getArchivePathFor, getArchivePathFor
6
7from Products.CMFCore.utils import getToolByName
8
9from Products.fatsyndication.adapters.feedentry import DocumentFeedEntry as BaseFeedEntry
10
11class 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
30class 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()
Note: See TracBrowser for help on using the repository browser.