File: feeds.py

package info (click to toggle)
python-django 1.2.3-3%2Bsqueeze15
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 29,720 kB
  • ctags: 21,538
  • sloc: python: 101,631; xml: 574; makefile: 149; sh: 121; sql: 7
file content (38 lines) | stat: -rw-r--r-- 1,374 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from django.contrib.syndication import views
from django.core.exceptions import ObjectDoesNotExist
import warnings

# This is part of the deprecated API
from django.contrib.syndication.views import FeedDoesNotExist, add_domain

class Feed(views.Feed):
    """Provided for backwards compatibility."""
    def __init__(self, slug, request):
        warnings.warn('The syndication feeds.Feed class is deprecated. Please '
                      'use the new class based view API.',
                      category=PendingDeprecationWarning)

        self.slug = slug
        self.request = request
        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)

    def get_object(self, bits):
        return None

    def get_feed(self, url=None):
        """
        Returns a feedgenerator.DefaultFeed object, fully populated, for
        this feed. Raises FeedDoesNotExist for invalid parameters.
        """
        if url:
            bits = url.split('/')
        else:
            bits = []
        try:
            obj = self.get_object(bits)
        except ObjectDoesNotExist:
            raise FeedDoesNotExist
        return super(Feed, self).get_feed(obj, self.request)