2010-01-28 21:46:18 +08:00
|
|
|
from django.contrib.syndication import views
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
|
|
|
import warnings
|
2008-08-06 01:38:49 +08:00
|
|
|
|
2010-01-28 21:46:18 +08:00
|
|
|
# This is part of the deprecated API
|
|
|
|
from django.contrib.syndication.views import FeedDoesNotExist, add_domain
|
2005-11-12 11:44:53 +08:00
|
|
|
|
2010-01-28 21:46:18 +08:00
|
|
|
class Feed(views.Feed):
|
|
|
|
"""Provided for backwards compatibility."""
|
2007-07-12 13:29:32 +08:00
|
|
|
def __init__(self, slug, request):
|
2010-01-28 21:46:18 +08:00
|
|
|
warnings.warn('The syndication feeds.Feed class is deprecated. Please '
|
|
|
|
'use the new class based view API.',
|
2010-10-11 20:20:07 +08:00
|
|
|
category=DeprecationWarning)
|
2010-01-28 21:46:18 +08:00
|
|
|
|
2005-11-12 11:44:53 +08:00
|
|
|
self.slug = slug
|
2007-07-12 13:29:32 +08:00
|
|
|
self.request = request
|
2010-01-28 21:46:18 +08:00
|
|
|
self.feed_url = getattr(self, 'feed_url', None) or request.path
|
|
|
|
self.title_template = self.title_template or ('feeds/%s_title.html' % slug)
|
|
|
|
self.description_template = self.description_template or ('feeds/%s_description.html' % slug)
|
2008-08-17 04:40:47 +08:00
|
|
|
|
2008-03-18 23:40:27 +08:00
|
|
|
def get_object(self, bits):
|
|
|
|
return None
|
|
|
|
|
2005-11-12 11:44:53 +08:00
|
|
|
def get_feed(self, url=None):
|
|
|
|
"""
|
|
|
|
Returns a feedgenerator.DefaultFeed object, fully populated, for
|
|
|
|
this feed. Raises FeedDoesNotExist for invalid parameters.
|
|
|
|
"""
|
|
|
|
if url:
|
2008-03-18 23:40:27 +08:00
|
|
|
bits = url.split('/')
|
2005-11-12 11:44:53 +08:00
|
|
|
else:
|
2008-03-18 23:40:27 +08:00
|
|
|
bits = []
|
|
|
|
try:
|
|
|
|
obj = self.get_object(bits)
|
|
|
|
except ObjectDoesNotExist:
|
|
|
|
raise FeedDoesNotExist
|
2010-01-28 21:46:18 +08:00
|
|
|
return super(Feed, self).get_feed(obj, self.request)
|
2005-11-12 11:44:53 +08:00
|
|
|
|