diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-07-12 05:29:32 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-07-12 05:29:32 +0000 |
| commit | 090aa5210ebd5ce3c79db95d3f04c95ed346f42a (patch) | |
| tree | 8811537abe6486c7a09e494aa6debcadfedbea14 /django | |
| parent | dcd5750d7ac6692428e431010772f1941406d576 (diff) | |
Improved syndication feed framework to use RequestSite if the sites framework is not installed -- i.e., the sites framework is no longer required to use the syndication feed framework. This is backwards incompatible if anybody has subclassed Feed and overridden __init__(), because the second parameter is now expected to be an HttpRequest object instead of request.path
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5654 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/syndication/feeds.py | 13 | ||||
| -rw-r--r-- | django/contrib/syndication/views.py | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py index 547afb17f3..eb5a9f0607 100644 --- a/django/contrib/syndication/feeds.py +++ b/django/contrib/syndication/feeds.py @@ -1,6 +1,6 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist from django.template import Context, loader, Template, TemplateDoesNotExist -from django.contrib.sites.models import Site +from django.contrib.sites.models import Site, RequestSite from django.utils import feedgenerator from django.utils.encoding import smart_unicode, iri_to_uri from django.conf import settings @@ -22,9 +22,10 @@ class Feed(object): title_template = None description_template = None - def __init__(self, slug, feed_url): + def __init__(self, slug, request): self.slug = slug - self.feed_url = feed_url + self.request = request + self.feed_url = request.path 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) @@ -67,7 +68,11 @@ class Feed(object): else: obj = None - current_site = Site.objects.get_current() + if Site._meta.installed: + current_site = Site.objects.get_current() + else: + current_site = RequestSite(self.request) + link = self.__get_dynamic_attr('link', obj) link = add_domain(current_site.domain, link) diff --git a/django/contrib/syndication/views.py b/django/contrib/syndication/views.py index 621665d4d4..423d333991 100644 --- a/django/contrib/syndication/views.py +++ b/django/contrib/syndication/views.py @@ -16,7 +16,7 @@ def feed(request, url, feed_dict=None): raise Http404, "Slug %r isn't registered." % slug try: - feedgen = f(slug, request.path).get_feed(param) + feedgen = f(slug, request).get_feed(param) except feeds.FeedDoesNotExist: raise Http404, "Invalid feed parameters. Slug %r is valid, but other parameters, or lack thereof, are not." % slug |
