summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-01-13 14:51:34 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-01-13 14:51:34 +0000
commit2d352444b0354f163ac7d04fcddf84cc744a09d8 (patch)
tree65a8fa4100fdc38f1a1e89b27852c466d454b9b5 /django
parent7b8c38250ce812c67bc85f454092c74ad5b81339 (diff)
Fixed #14176 -- Added forwards compatibility to the legacy syndication feed view. This allows class-based feeds to be deployed using the old-style feed view, as long as the feed requires no arguments (i.e., get_object returns None). Thanks to psychcf for the report, cwhaines for the investigation, and Andrew Godwin for the assist.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15189 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/contrib/syndication/views.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/django/contrib/syndication/views.py b/django/contrib/syndication/views.py
index ee692e2c0c..9228e91687 100644
--- a/django/contrib/syndication/views.py
+++ b/django/contrib/syndication/views.py
@@ -188,6 +188,7 @@ class Feed(object):
def feed(request, url, feed_dict=None):
"""Provided for backwards compatibility."""
+ from django.contrib.syndication.feeds import Feed as LegacyFeed
import warnings
warnings.warn('The syndication feed() view is deprecated. Please use the '
'new class based view API.',
@@ -206,6 +207,18 @@ def feed(request, url, feed_dict=None):
except KeyError:
raise Http404("Slug %r isn't registered." % slug)
+ # Backwards compatibility within the backwards compatibility;
+ # Feeds can be updated to be class-based, but still be deployed
+ # using the legacy feed view. This only works if the feed takes
+ # no arguments (i.e., get_object returns None). Refs #14176.
+ if not issubclass(f, LegacyFeed):
+ instance = f()
+ instance.feed_url = getattr(f, 'feed_url', None) or request.path
+ instance.title_template = f.title_template or ('feeds/%s_title.html' % slug)
+ instance.description_template = f.description_template or ('feeds/%s_description.html' % slug)
+
+ return instance(request)
+
try:
feedgen = f(slug, request).get_feed(param)
except FeedDoesNotExist: