summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-06-26 23:19:03 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-06-26 23:19:03 +0000
commite923ed2a83a08ba2db7347e5d467f26949fa4877 (patch)
tree7dcf669a96b7b3bba98b92f9c7fc104ac62388b3 /django
parent6dc719312df548dd5766b79b1e4c947c54285b93 (diff)
Fixed #2158 -- Added title_template and description_template hooks to Feed class in syndication framework.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3214 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/contrib/syndication/feeds.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py
index 3deefc5866..e648c6c746 100644
--- a/django/contrib/syndication/feeds.py
+++ b/django/contrib/syndication/feeds.py
@@ -16,10 +16,14 @@ class Feed(object):
item_pubdate = None
item_enclosure_url = None
feed_type = feedgenerator.DefaultFeed
+ title_template = None
+ description_template = None
def __init__(self, slug, feed_url):
self.slug = slug
self.feed_url = feed_url
+ self.title_template_name = self.title_template or ('feeds/%s_title.html' % slug)
+ self.description_template_name = self.description_template or ('feeds/%s_description.html' % slug)
def item_link(self, item):
try:
@@ -77,13 +81,13 @@ class Feed(object):
)
try:
- title_template = loader.get_template('feeds/%s_title.html' % self.slug)
+ title_tmp = loader.get_template(self.title_template_name)
except TemplateDoesNotExist:
- title_template = Template('{{ obj }}')
+ title_tmp = Template('{{ obj }}')
try:
- description_template = loader.get_template('feeds/%s_description.html' % self.slug)
+ description_tmp = loader.get_template(self.description_template_name)
except TemplateDoesNotExist:
- description_template = Template('{{ obj }}')
+ description_tmp = Template('{{ obj }}')
for item in self.__get_dynamic_attr('items', obj):
link = add_domain(current_site.domain, self.__get_dynamic_attr('item_link', item))
@@ -102,9 +106,9 @@ class Feed(object):
else:
author_email = author_link = None
feed.add_item(
- title = title_template.render(Context({'obj': item, 'site': current_site})).decode('utf-8'),
+ title = title_tmp.render(Context({'obj': item, 'site': current_site})).decode('utf-8'),
link = link,
- description = description_template.render(Context({'obj': item, 'site': current_site})).decode('utf-8'),
+ description = description_tmp.render(Context({'obj': item, 'site': current_site})).decode('utf-8'),
unique_id = link,
enclosure = enc,
pubdate = self.__get_dynamic_attr('item_pubdate', item),