PageRenderTime 46ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/django/contrib/syndication/feeds.py

https://code.google.com/p/mango-py/
Python | 38 lines | 26 code | 6 blank | 6 comment | 4 complexity | 3f0b956717a7db5a64cae7d6d4595f6b MD5 | raw file
 1from django.contrib.syndication import views
 2from django.core.exceptions import ObjectDoesNotExist
 3import warnings
 4
 5# This is part of the deprecated API
 6from django.contrib.syndication.views import FeedDoesNotExist, add_domain
 7
 8class Feed(views.Feed):
 9    """Provided for backwards compatibility."""
10    def __init__(self, slug, request):
11        warnings.warn('The syndication feeds.Feed class is deprecated. Please '
12                      'use the new class based view API.',
13                      category=DeprecationWarning)
14
15        self.slug = slug
16        self.request = request
17        self.feed_url = getattr(self, 'feed_url', None) or request.path
18        self.title_template = self.title_template or ('feeds/%s_title.html' % slug)
19        self.description_template = self.description_template or ('feeds/%s_description.html' % slug)
20
21    def get_object(self, bits):
22        return None
23
24    def get_feed(self, url=None):
25        """
26        Returns a feedgenerator.DefaultFeed object, fully populated, for
27        this feed. Raises FeedDoesNotExist for invalid parameters.
28        """
29        if url:
30            bits = url.split('/')
31        else:
32            bits = []
33        try:
34            obj = self.get_object(bits)
35        except ObjectDoesNotExist:
36            raise FeedDoesNotExist
37        return super(Feed, self).get_feed(obj, self.request)
38