Ticket #8989: 8989_add_atomlink.diff

File 8989_add_atomlink.diff, 1.8 KB (added by Arthur Koziel, 16 years ago)
  • django/utils/feedgenerator.py

    diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
    index de924a3..7e22ee8 100644
    a b class RssFeed(SyndicationFeed):  
    186186        handler.endElement(u"rss")
    187187
    188188    def rss_attributes(self):
    189         return {u"version": self._version}
     189        return {u"version": self._version,
     190                u"xmlns:atom": "http://www.w3.org/2005/Atom"}
    190191
    191192    def write_items(self, handler):
    192193        for item in self.items:
    class RssFeed(SyndicationFeed):  
    198199        handler.addQuickElement(u"title", self.feed['title'])
    199200        handler.addQuickElement(u"link", self.feed['link'])
    200201        handler.addQuickElement(u"description", self.feed['description'])
     202        handler.addQuickElement(u"atom:link", None, {u"rel": u"self", u"href": self.feed['feed_url']})
    201203        if self.feed['language'] is not None:
    202204            handler.addQuickElement(u"language", self.feed['language'])
    203205        for cat in self.feed['categories']:
  • tests/regressiontests/syndication/tests.py

    diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py
    index 1410ed7..34a0a1b 100644
    a b class SyndicationFeedTest(TestCase):  
    3333        chan_elem = feed.getElementsByTagName('channel')
    3434        self.assertEqual(len(chan_elem), 1)
    3535        chan = chan_elem[0]
    36         self.assertChildNodes(chan, ['title', 'link', 'description', 'language', 'lastBuildDate', 'item'])
     36        self.assertChildNodes(chan, ['title', 'link', 'description', 'language', 'lastBuildDate', 'item', 'atom:link'])
    3737   
    3838        items = chan.getElementsByTagName('item')
    3939        self.assertEqual(len(items), Entry.objects.count())
Back to Top