summaryrefslogtreecommitdiff
path: root/django/contrib
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-14 05:15:40 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-14 05:15:40 +0000
commit74865663bbaddf4d2d8cd5472e2f137ebe0ec347 (patch)
tree791def3ff75381f689a7a33c69a518520dd18520 /django/contrib
parent7626cb058107ac1ecb0795162e4c9fc4f92356dd (diff)
Fixed #787 -- High-level syndication framework now picks up author details. Also updated documentation. Thanks, mattycakes
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1228 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/contrib')
-rw-r--r--django/contrib/syndication/feeds.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py
index 8b49334fec..49b34858dc 100644
--- a/django/contrib/syndication/feeds.py
+++ b/django/contrib/syndication/feeds.py
@@ -27,8 +27,11 @@ class Feed:
except AttributeError:
raise ImproperlyConfigured, "Give your %s class a get_absolute_url() method, or define an item_link() method in your Feed class." % item.__class__.__name__
- def __get_dynamic_attr(self, attname, obj):
- attr = getattr(self, attname)
+ def __get_dynamic_attr(self, attname, obj, default=None):
+ try:
+ attr = getattr(self, attname)
+ except AttributeError:
+ return default
if callable(attr):
try:
return attr(obj)
@@ -59,6 +62,9 @@ class Feed:
description = self.__get_dynamic_attr('description', obj),
language = LANGUAGE_CODE.decode(),
feed_url = add_domain(current_site, self.feed_url),
+ author_name = self.__get_dynamic_attr('author_name', obj),
+ author_link = self.__get_dynamic_attr('author_link', obj),
+ author_email = self.__get_dynamic_attr('author_email', obj),
)
try:
@@ -80,6 +86,12 @@ class Feed:
length = str(self.__get_dynamic_attr('item_enclosure_length', item)).decode('utf-8'),
mime_type = self.__get_dynamic_attr('item_enclosure_mime_type', item).decode('utf-8'),
)
+ author_name = self.__get_dynamic_attr('item_author_name', item)
+ if author_name is not None:
+ author_email = self.__get_dynamic_attr('item_author_email', item)
+ author_link = self.__get_dynamic_attr('item_author_link', item)
+ else:
+ author_email = author_link = None
feed.add_item(
title = title_template.render(Context({'obj': item, 'site': current_site})).decode('utf-8'),
link = link,
@@ -87,5 +99,8 @@ class Feed:
unique_id = link,
enclosure = enc,
pubdate = self.__get_dynamic_attr('item_pubdate', item),
+ author_name = author_name,
+ author_email = author_email,
+ author_link = author_link,
)
return feed