Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #14202 -- made the atom:link element optional in feeds.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17029 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 965c5d7cced0d2e09f5b0c3165c192ab4334331b 1 parent 59c051d
@aaugustin aaugustin authored
View
4 django/utils/feedgenerator.py
@@ -224,7 +224,9 @@ def add_root_elements(self, handler):
handler.addQuickElement(u"title", self.feed['title'])
handler.addQuickElement(u"link", self.feed['link'])
handler.addQuickElement(u"description", self.feed['description'])
- handler.addQuickElement(u"atom:link", None, {u"rel": u"self", u"href": self.feed['feed_url']})
+ if self.feed['feed_url'] is not None:
+ handler.addQuickElement(u"atom:link", None,
+ {u"rel": u"self", u"href": self.feed['feed_url']})
if self.feed['language'] is not None:
handler.addQuickElement(u"language", self.feed['language'])
for cat in self.feed['categories']:
View
13 tests/regressiontests/utils/feedgenerator.py
@@ -87,3 +87,16 @@ def test_atom1_mime_type(self):
atom_feed.mime_type, "application/atom+xml; charset=utf-8"
)
+ # Two regression tests for #14202
+
+ def test_feed_without_feed_url_gets_rendered_without_atom_link(self):
+ feed = feedgenerator.Rss201rev2Feed('title', '/link/', 'descr')
+ self.assertEquals(feed.feed['feed_url'], None)
+ feed_content = feed.writeString('utf-8')
+ self.assertNotIn('<atom:link href=', feed_content)
+
+ def test_feed_with_feed_url_gets_rendered_with_atom_link(self):
+ feed = feedgenerator.Rss201rev2Feed('title', '/link/', 'descr', feed_url='/feed/')
+ self.assertEquals(feed.feed['feed_url'], '/feed/')
+ feed_content = feed.writeString('utf-8')
+ self.assertIn('<atom:link href="/feed/" rel="self"></atom:link>', feed_content)
Please sign in to comment.
Something went wrong with that request. Please try again.