Ticket #3502: feed_ttl.2.diff

File feed_ttl.2.diff, 4.4 KB (added by Thomas Kerpe, 17 years ago)

Patch against [6188]

  • django/contrib/syndication/feeds.py

     
    8989            categories = self.__get_dynamic_attr('categories', obj),
    9090            feed_copyright = self.__get_dynamic_attr('feed_copyright', obj),
    9191            feed_guid = self.__get_dynamic_attr('feed_guid', obj),
     92            ttl = self.__get_dynamic_attr('ttl', obj),
    9293        )
    9394
    9495        try:
  • django/utils/feedgenerator.py

     
    4141    "Base class for all syndication feeds. Subclasses should provide write()"
    4242    def __init__(self, title, link, description, language=None, author_email=None,
    4343            author_name=None, author_link=None, subtitle=None, categories=None,
    44             feed_url=None, feed_copyright=None, feed_guid=None):
     44            feed_url=None, feed_copyright=None, feed_guid=None, ttl=None):
    4545        to_unicode = lambda s: force_unicode(s, strings_only=True)
    4646        if categories:
    4747            categories = [force_unicode(c) for c in categories]
     
    5858            'feed_url': iri_to_uri(feed_url),
    5959            'feed_copyright': to_unicode(feed_copyright),
    6060            'id': feed_guid or link,
     61            'ttl': ttl,
    6162        }
    6263        self.items = []
    6364
    6465    def add_item(self, title, link, description, author_email=None,
    6566        author_name=None, author_link=None, pubdate=None, comments=None,
    66         unique_id=None, enclosure=None, categories=(), item_copyright=None):
     67        unique_id=None, enclosure=None, categories=(), item_copyright=None, ttl=None):
    6768        """
    6869        Adds an item to the feed. All args are expected to be Python Unicode
    6970        objects except pubdate, which is a datetime.datetime object, and
     
    8586            'enclosure': enclosure,
    8687            'categories': categories or (),
    8788            'item_copyright': to_unicode(item_copyright),
     89            'ttl': ttl,
    8890        })
    8991
    9092    def num_items(self):
     
    142144        if self.feed['feed_copyright'] is not None:
    143145            handler.addQuickElement(u"copyright", self.feed['feed_copyright'])
    144146        handler.addQuickElement(u"lastBuildDate", rfc2822_date(self.latest_post_date()).decode('ascii'))
     147        if self.feed['ttl'] is not None:
     148            handler.addQuickElement(u"ttl", self.feed['ttl'])
    145149        self.write_items(handler)
    146150        self.endChannelElement(handler)
    147151        handler.endElement(u"rss")
     
    186190                handler.addQuickElement(u"comments", item['comments'])
    187191            if item['unique_id'] is not None:
    188192                handler.addQuickElement(u"guid", item['unique_id'])
     193            if item['ttl'] is not None:
     194                handler.addQuickElement(u"ttl", item['ttl'])
    189195
    190196            # Enclosure.
    191197            if item['enclosure'] is not None:
  • AUTHORS

     
    163163    Nagy Károly <charlie@rendszergazda.com>
    164164    Ben Dean Kawamura <ben.dean.kawamura@gmail.com>
    165165    Ian G. Kelly <ian.g.kelly@gmail.com>
     166    Thomas Kerpe <thomas@kerpe.net>
    166167    Ben Khoo <khoobks@westnet.com.au>
    167168    Garth Kidd <http://www.deadlybloodyserious.com/>
    168169    kilian <kilian.cavalotti@lip6.fr>
  • docs/syndication_feeds.txt

     
    547547
    548548        copyright = 'Copyright (c) 2007, Sally Smith' # Hard-coded copyright notice.
    549549
     550        # TTL -- One of the following three is optional. The
     551        # framework looks for them in this order.
     552
     553        def ttl(self, obj):
     554            """
     555            Takes the object returned by get_object() and returns the feed's
     556            TTL (Time to live) as a normal Python string.
     557            """
     558
     559        def ttl(self):
     560            """
     561            Returns the feed's ttl as a normal Python string.
     562            """
     563
     564        ttl = 600 # Hard-coded Time to live.
     565
     566
     567
    550568        # ITEMS -- One of the following three is required. The framework looks
    551569        # for them in this order.
    552570
Back to Top