Ticket #2158: syndication.diff
File syndication.diff, 2.2 KB (added by , 18 years ago) |
---|
-
syndication/views.py
1 1 from django.contrib.syndication import feeds 2 2 from django.http import HttpResponse, Http404 3 3 4 def feed(request, url, feed_dict=None ):4 def feed(request, url, feed_dict=None, description_template=None, title_template=None): 5 5 if not feed_dict: 6 6 raise Http404, "No feeds are registered." 7 7 … … 15 15 except KeyError: 16 16 raise Http404, "Slug %r isn't registered." % slug 17 17 18 desc = description_template 19 title = title_template 20 18 21 try: 19 feedgen = f(slug, request.path).get_feed(param )22 feedgen = f(slug, request.path).get_feed(param, desc, title) 20 23 except feeds.FeedDoesNotExist: 21 24 raise Http404, "Invalid feed parameters. Slug %r is valid, but other parameters, or lack thereof, are not." % slug 22 25 -
syndication/feeds.py
47 47 return attr() 48 48 return attr 49 49 50 def get_feed(self, url=None ):50 def get_feed(self, url=None, desc_temp=None, title_temp=None): 51 51 """ 52 52 Returns a feedgenerator.DefaultFeed object, fully populated, for 53 53 this feed. Raises FeedDoesNotExist for invalid parameters. … … 76 76 ) 77 77 78 78 try: 79 title_template = loader.get_template('feeds/%s_title.html' % self.slug) 79 if title_temp: 80 title_template = loader.get_template(title_temp) 81 else: 82 title_template = loader.get_template('feeds/%s_title.html' % self.slug) 80 83 except TemplateDoesNotExist: 81 84 title_template = Template('{{ obj }}') 82 85 try: 83 description_template = loader.get_template('feeds/%s_description.html' % self.slug) 86 if desc_temp: 87 description_template = loader.get_template(desc_temp) 88 else: 89 description_template = loader.get_template('feeds/%s_description.html' % self.slug) 84 90 except TemplateDoesNotExist: 85 91 description_template = Template('{{ obj }}') 86 92