2011-07-13 17:36:07 +08:00
|
|
|
from django.http import Http404
|
2012-02-05 05:01:11 +08:00
|
|
|
from django.utils.translation import ugettext as _
|
2011-07-13 17:36:07 +08:00
|
|
|
|
|
|
|
def feed(request, url, feed_dict=None):
|
|
|
|
"""Provided for backwards compatibility."""
|
|
|
|
if not feed_dict:
|
2012-02-05 05:01:11 +08:00
|
|
|
raise Http404(_(u"No feeds are registered."))
|
2011-07-13 17:36:07 +08:00
|
|
|
|
|
|
|
try:
|
|
|
|
slug, param = url.split('/', 1)
|
|
|
|
except ValueError:
|
|
|
|
slug, param = url, ''
|
|
|
|
|
|
|
|
try:
|
|
|
|
f = feed_dict[slug]
|
|
|
|
except KeyError:
|
2012-02-05 05:01:11 +08:00
|
|
|
raise Http404(_(u"Slug %r isn't registered.") % slug)
|
2011-07-13 17:36:07 +08:00
|
|
|
|
|
|
|
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)
|