diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-11-14 04:59:20 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-11-14 04:59:20 +0000 |
| commit | 7626cb058107ac1ecb0795162e4c9fc4f92356dd (patch) | |
| tree | ad0274d4cd36b067ca80f2d4eea698a8efdc2290 /django/utils | |
| parent | 7b315b47aa09611ff293fd6cfaf21b86f7045a2b (diff) | |
Improved Atom feed-generating framework to output <link rel='self'>. Added a feed_url hook to feedgenerator for this purpose, and changed the syndication Feed and views to use it. Also updated docs.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1227 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/feedgenerator.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py index 86c1a046ec..a8dd5c39df 100644 --- a/django/utils/feedgenerator.py +++ b/django/utils/feedgenerator.py @@ -41,7 +41,8 @@ def get_tag_uri(url, date): class SyndicationFeed: "Base class for all syndication feeds. Subclasses should provide write()" def __init__(self, title, link, description, language=None, author_email=None, - author_name=None, author_link=None, subtitle=None, categories=None): + author_name=None, author_link=None, subtitle=None, categories=None, + feed_url=None): self.feed = { 'title': title, 'link': link, @@ -52,6 +53,7 @@ class SyndicationFeed: 'author_link': author_link, 'subtitle': subtitle, 'categories': categories or (), + 'feed_url': feed_url, } self.items = [] @@ -190,7 +192,9 @@ class Atom1Feed(SyndicationFeed): else: handler.startElement(u"feed", {u"xmlns": self.ns}) handler.addQuickElement(u"title", self.feed['title']) - handler.addQuickElement(u"link", "", {u"href": self.feed['link']}) + handler.addQuickElement(u"link", "", {u"rel": u"alternate", u"href": self.feed['link']}) + if self.feed['feed_url'] is not None: + handler.addQuickElement(u"link", "", {u"rel": u"self", u"href": self.feed['feed_url']}) handler.addQuickElement(u"id", self.feed['link']) handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('ascii')) if self.feed['author_name'] is not None: |
