Django

Code

Changeset 3143

Show
Ignore:
Timestamp:
06/18/06 20:38:06 (2 years ago)
Author:
mtredinnick
Message:

Fixed #1473 -- Added support for categories back into syndication feeds
(was accidently removed in r1994). Thanks, k.shaposhnikov@gmail.com

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/syndication/feeds.py

    r3113 r3143  
    7474            author_link = self.__get_dynamic_attr('author_link', obj), 
    7575            author_email = self.__get_dynamic_attr('author_email', obj), 
     76            categories = self.__get_dynamic_attr('categories', obj), 
    7677        ) 
    7778 
     
    111112                author_email = author_email, 
    112113                author_link = author_link, 
     114                categories = self.__get_dynamic_attr('item_categories', item), 
    113115            ) 
    114116        return feed 
  • django/trunk/django/utils/feedgenerator.py

    r3113 r3143  
    127127        if self.feed['language'] is not None: 
    128128            handler.addQuickElement(u"language", self.feed['language']) 
     129        for cat in self.feed['categories']: 
     130            handler.addQuickElement(u"category", cat) 
    129131        self.write_items(handler) 
    130132        self.endChannelElement(handler) 
  • django/trunk/docs/syndication_feeds.txt

    r2809 r3143  
    440440        author_link = 'http://www.example.com/' # Hard-coded author URL. 
    441441 
     442        # CATEGORIES -- One of the following three is optional. The framework 
     443        # looks for them in this order. In each case, the method/attribute 
     444        # should return an iterable object that returns strings. 
     445 
     446        def categories(self, obj): 
     447            """ 
     448            Takes the object returned by get_object() and returns the feed's 
     449            categories as iterable over strings. 
     450            """ 
     451 
     452        def categories(self): 
     453            """ 
     454            Returns the feed's categories as iterable over strings. 
     455            """ 
     456 
     457        categories = ("python", "django") # Hard-coded list of categories. 
     458 
    442459        # ITEMS -- One of the following three is required. The framework looks 
    443460        # for them in this order. 
     
    602619 
    603620        item_pubdate = datetime.datetime(2005, 5, 3) # Hard-coded pubdate. 
     621 
     622        # ITEM CATEGORIES -- It's optional to use one of these three. This is 
     623        # a hook that specifies how to get the list of categories for a given 
     624        # item. In each case, the method/attribute should return an iterable 
     625        # object that returns strings. 
     626 
     627        def item_categories(self, item): 
     628            """ 
     629            Takes an item, as returned by items(), and returns the item's 
     630            categories. 
     631            """ 
     632 
     633        def item_categories(self): 
     634            """ 
     635            Returns the categories for every item in the feed. 
     636            """ 
     637 
     638        item_categories = ("python", "django") # Hard-coded categories. 
     639 
    604640 
    605641The low-level framework