Ticket #3624: item_title_and_description_methods.patch
File item_title_and_description_methods.patch, 2.6 KB (added by , 16 years ago) |
---|
-
django/contrib/syndication/feeds.py
30 30 self.title_template_name = self.title_template or ('feeds/%s_title.html' % slug) 31 31 self.description_template_name = self.description_template or ('feeds/%s_description.html' % slug) 32 32 33 def item_title(self, item): 34 if not hasattr(self, '_title_tmp'): 35 try: 36 self._title_tmp = loader.get_template(self.title_template_name) 37 except TemplateDoesNotExist: 38 self._title_tmp = Template('{{ obj }}') 39 return self._title_tmp.render(RequestContext(self.request, {'obj': item })) 40 41 def item_description(self, item): 42 if not hasattr(self, '_description_tmp'): 43 try: 44 self._description_tmp = loader.get_template(self.description_template_name) 45 except TemplateDoesNotExist: 46 self._description_tmp = Template('{{ obj }}') 47 return self._description_tmp.render(RequestContext(self.request, {'obj': item })) 48 33 49 def item_link(self, item): 34 50 try: 35 51 return item.get_absolute_url() … … 99 115 ttl = self.__get_dynamic_attr('ttl', obj), 100 116 ) 101 117 102 try:103 title_tmp = loader.get_template(self.title_template_name)104 except TemplateDoesNotExist:105 title_tmp = Template('{{ obj }}')106 try:107 description_tmp = loader.get_template(self.description_template_name)108 except TemplateDoesNotExist:109 description_tmp = Template('{{ obj }}')110 118 111 119 for item in self.__get_dynamic_attr('items', obj): 112 120 link = add_domain(current_site.domain, self.__get_dynamic_attr('item_link', item)) … … 125 133 else: 126 134 author_email = author_link = None 127 135 feed.add_item( 128 title = title_tmp.render(RequestContext(self.request, {'obj': item, 'site': current_site})),136 title = self.__get_dynamic_attr('item_title', item), 129 137 link = link, 130 description = description_tmp.render(RequestContext(self.request, {'obj': item, 'site': current_site})),138 description = self.__get_dynamic_attr('item_description', item), 131 139 unique_id = self.__get_dynamic_attr('item_guid', item, link), 132 140 enclosure = enc, 133 141 pubdate = self.__get_dynamic_attr('item_pubdate', item),