Django

Code

Changeset 4478

Show
Ignore:
Timestamp:
02/10/07 02:36:39 (2 years ago)
Author:
mtredinnick
Message:

Fixed #2762 -- added copyright element support to RSS and Atom feeds. Patch
from Jonathan Buchanan.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/AUTHORS

    r4477 r4478  
    4545    akaihola 
    4646    Andreas 
     47    andy@jadedplanet.net 
    4748    ant9000@netwise.it 
    4849    David Ascher <http://ascher.ca/> 
     
    5657    Simon Blanchard 
    5758    Andrew Brehaut <http://brehaut.net/blog> 
    58     andy@jadedplanet.net 
     59    Jonathan Buchanan <jonathan.buchanan@gmail.com> 
    5960    Antonio Cavedoni <http://cavedoni.com/> 
    6061    C8E 
  • django/trunk/django/contrib/syndication/feeds.py

    r4265 r4478  
    7979            author_email = self.__get_dynamic_attr('author_email', obj), 
    8080            categories = self.__get_dynamic_attr('categories', obj), 
     81            feed_copyright = self.__get_dynamic_attr('feed_copyright', obj), 
    8182        ) 
    8283 
     
    117118                author_link = author_link, 
    118119                categories = self.__get_dynamic_attr('item_categories', item), 
     120                item_copyright = self.__get_dynamic_attr('item_copyright', item), 
    119121            ) 
    120122        return feed 
  • django/trunk/django/utils/feedgenerator.py

    r4265 r4478  
    4141    def __init__(self, title, link, description, language=None, author_email=None, 
    4242            author_name=None, author_link=None, subtitle=None, categories=None, 
    43             feed_url=None): 
     43            feed_url=None, feed_copyright=None): 
    4444        self.feed = { 
    4545            'title': title, 
     
    5353            'categories': categories or (), 
    5454            'feed_url': feed_url, 
     55            'feed_copyright': feed_copyright, 
    5556        } 
    5657        self.items = [] 
     
    5859    def add_item(self, title, link, description, author_email=None, 
    5960        author_name=None, author_link=None, pubdate=None, comments=None, 
    60         unique_id=None, enclosure=None, categories=()): 
     61        unique_id=None, enclosure=None, categories=(), item_copyright=None): 
    6162        """ 
    6263        Adds an item to the feed. All args are expected to be Python Unicode 
     
    7677            'enclosure': enclosure, 
    7778            'categories': categories or (), 
     79            'item_copyright': item_copyright, 
    7880        }) 
    7981 
     
    129131        for cat in self.feed['categories']: 
    130132            handler.addQuickElement(u"category", cat) 
     133        if self.feed['feed_copyright'] is not None: 
     134            handler.addQuickElement(u"copyright", self.feed['feed_copyright']) 
    131135        self.write_items(handler) 
    132136        self.endChannelElement(handler) 
     
    213217        for cat in self.feed['categories']: 
    214218            handler.addQuickElement(u"category", "", {u"term": cat}) 
     219        if self.feed['feed_copyright'] is not None: 
     220            handler.addQuickElement(u"rights", self.feed['feed_copyright']) 
    215221        self.write_items(handler) 
    216222        handler.endElement(u"feed") 
     
    253259                     u"type": item['enclosure'].mime_type}) 
    254260 
    255             # Categories: 
     261            # Categories. 
    256262            for cat in item['categories']: 
    257263                handler.addQuickElement(u"category", u"", {u"term": cat}) 
     264 
     265            # Rights. 
     266            if item['item_copyright'] is not None: 
     267                handler.addQuickElement(u"rights", item['item_copyright']) 
    258268 
    259269            handler.endElement(u"entry") 
  • django/trunk/docs/syndication_feeds.txt

    r4420 r4478  
    128128 
    129129          * ``{{ obj }}`` -- The current object (one of whichever objects you 
    130             returned in ``items()``).  
     130            returned in ``items()``). 
    131131          * ``{{ site }}`` -- A ``django.models.core.sites.Site`` object 
    132132            representing the current site. This is useful for 
     
    479479        categories = ("python", "django") # Hard-coded list of categories. 
    480480 
     481        # COPYRIGHT NOTICE -- One of the following three is optional. The 
     482        # framework looks for them in this order. 
     483 
     484        def copyright(self, obj): 
     485            """ 
     486            Takes the object returned by get_object() and returns the feed's 
     487            copyright notice as a normal Python string. 
     488            """ 
     489 
     490        def copyright(self): 
     491            """ 
     492            Returns the feed's copyright notice as a normal Python string. 
     493            """ 
     494 
     495        copyright = 'Copyright (c) 2007, Sally Smith' # Hard-coded copyright notice. 
     496 
    481497        # ITEMS -- One of the following three is required. The framework looks 
    482498        # for them in this order. 
     
    659675 
    660676        item_categories = ("python", "django") # Hard-coded categories. 
     677 
     678        # ITEM COPYRIGHT NOTICE (only applicable to Atom feeds) -- One of the 
     679        # following three is optional. The framework looks for them in this 
     680        # order. 
     681 
     682        def item_copyright(self, obj): 
     683            """ 
     684            Takes an item, as returned by items(), and returns the item's 
     685            copyright notice as a normal Python string. 
     686            """ 
     687 
     688        def item_copyright(self): 
     689            """ 
     690            Returns the copyright notice for every item in the feed. 
     691            """ 
     692 
     693        item_copyright = 'Copyright (c) 2007, Sally Smith' # Hard-coded copyright notice. 
    661694 
    662695