Ticket #447: rss-pubdate.3.diff
File rss-pubdate.3.diff, 2.1 KB (added by , 19 years ago) |
---|
-
django/core/rss.py
8 8 class FeedConfiguration: 9 9 def __init__(self, slug, title_cb, link_cb, description_cb, get_list_func_cb, get_list_kwargs, 10 10 param_func=None, param_kwargs_cb=None, get_list_kwargs_cb=None, 11 enc_url=None, enc_length=None, enc_mime_type=None):11 get_pubdate_cb=None, enc_url=None, enc_length=None, enc_mime_type=None): 12 12 """ 13 13 slug -- Normal Python string. Used to register the feed. 14 14 … … 29 29 get_list_kwargs_cb -- Function that takes the param and returns a 30 30 dictionary to use in addition to get_list_kwargs (if applicable). 31 31 32 get_pubdate_cb -- Function that takes the object and returns a 33 datetime to use as the publication date. 34 32 35 The three enc_* parameters are strings representing methods or 33 36 attributes to call on a particular item to get its enclosure 34 37 information. Each of those methods/attributes should return a normal … … 45 48 self.enc_url = enc_url 46 49 self.enc_length = enc_length 47 50 self.enc_mime_type = enc_mime_type 51 self.get_pubdate_cb = get_pubdate_cb 48 52 49 53 def get_feed(self, param_slug=None): 50 54 """ … … 89 93 pass 90 94 enc = feedgenerator.Enclosure(enc_url.decode('utf-8'), 91 95 (enc_length and str(enc_length).decode('utf-8') or ''), enc_mime_type.decode('utf-8')) 96 pubdate = None 97 if self.get_pubdate_cb is not None: 98 pubdate = self.get_pubdate_cb(obj) 92 99 f.add_item( 93 100 title = title_template.render(Context({'obj': obj, 'site': current_site})).decode('utf-8'), 94 101 link = link, 95 102 description = description_template.render(Context({'obj': obj, 'site': current_site})).decode('utf-8'), 96 103 unique_id=link, 97 104 enclosure=enc, 105 pubdate=pubdate, 98 106 ) 99 107 return f 100 108