Ticket #447: rss-pubdate.2.diff

File rss-pubdate.2.diff, 1.7 KB (added by benno@…, 10 years ago)

Fixed version that deals with get_pubdate_cb being None.

  • django/core/rss.py

     
    88class FeedConfiguration:
    99    def __init__(self, slug, title_cb, link_cb, description_cb, get_list_func_cb, get_list_kwargs,
    1010        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):
    1212        """
    1313        slug -- Normal Python string. Used to register the feed.
    1414
     
    2929        get_list_kwargs_cb -- Function that takes the param and returns a
    3030        dictionary to use in addition to get_list_kwargs (if applicable).
    3131
     32        get_pubdate_cb -- Function that takes the object and returns a
     33        datetime to use as the publication date.
     34
    3235        The three enc_* parameters are strings representing methods or
    3336        attributes to call on a particular item to get its enclosure
    3437        information. Each of those methods/attributes should return a normal
     
    4548        self.enc_url = enc_url
    4649        self.enc_length = enc_length
    4750        self.enc_mime_type = enc_mime_type
     51        if self.get_pubdate_cb is not None:
     52            self.get_pubdate_cb = get_pubdate_cb
    4853       
    4954    def get_feed(self, param_slug=None):
    5055        """
     
    95100                description = description_template.render(Context({'obj': obj, 'site': current_site})).decode('utf-8'),
    96101                unique_id=link,
    97102                enclosure=enc,
     103                pubdate=self.get_pubdate_cb(obj)
    98104            )
    99105        return f
    100106       
Back to Top