Ticket #447: rss-pubdate.3.diff

File rss-pubdate.3.diff, 2.1 KB (added by benno@…, 19 years ago)

This time for sure.

  • 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        self.get_pubdate_cb = get_pubdate_cb
    4852       
    4953    def get_feed(self, param_slug=None):
    5054        """
     
    8993                    pass
    9094                enc = feedgenerator.Enclosure(enc_url.decode('utf-8'),
    9195                    (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)
    9299            f.add_item(
    93100                title = title_template.render(Context({'obj': obj, 'site': current_site})).decode('utf-8'),
    94101                link = link,
    95102                description = description_template.render(Context({'obj': obj, 'site': current_site})).decode('utf-8'),
    96103                unique_id=link,
    97104                enclosure=enc,
     105                pubdate=pubdate,
    98106            )
    99107        return f
    100108       
Back to Top