Code

Ticket #8989: 8989_add_atomlink_r10680.diff

File 8989_add_atomlink_r10680.diff, 1.8 KB (added by arthurk, 5 years ago)

Update patch to r10680

Line 
1diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
2index de924a3..7e22ee8 100644
3--- a/django/utils/feedgenerator.py
4+++ b/django/utils/feedgenerator.py
5@@ -186,7 +186,8 @@ class RssFeed(SyndicationFeed):
6         handler.endElement(u"rss")
7 
8     def rss_attributes(self):
9-        return {u"version": self._version}
10+        return {u"version": self._version,
11+                u"xmlns:atom": "http://www.w3.org/2005/Atom"}
12 
13     def write_items(self, handler):
14         for item in self.items:
15@@ -198,6 +199,7 @@ class RssFeed(SyndicationFeed):
16         handler.addQuickElement(u"title", self.feed['title'])
17         handler.addQuickElement(u"link", self.feed['link'])
18         handler.addQuickElement(u"description", self.feed['description'])
19+        handler.addQuickElement(u"atom:link", None, {u"rel": u"self", u"href": self.feed['feed_url']})
20         if self.feed['language'] is not None:
21             handler.addQuickElement(u"language", self.feed['language'])
22         for cat in self.feed['categories']:
23diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py
24index 816cb44..fb892f4 100644
25--- a/tests/regressiontests/syndication/tests.py
26+++ b/tests/regressiontests/syndication/tests.py
27@@ -35,7 +35,7 @@ class SyndicationFeedTest(TestCase):
28         chan_elem = feed.getElementsByTagName('channel')
29         self.assertEqual(len(chan_elem), 1)
30         chan = chan_elem[0]
31-        self.assertChildNodes(chan, ['title', 'link', 'description', 'language', 'lastBuildDate', 'item'])
32+        self.assertChildNodes(chan, ['title', 'link', 'description', 'language', 'lastBuildDate', 'item', 'atom:link'])
33     
34         items = chan.getElementsByTagName('item')
35         self.assertEqual(len(items), Entry.objects.count())