Ticket #12978: 12968.diff

File 12968.diff, 2.4 KB (added by Yuval Adam, 14 years ago)
  • django/utils/feedgenerator.py

    ### Eclipse Workspace Patch 1.0
    #P django-trunk
     
    7171    "Base class for all syndication feeds. Subclasses should provide write()"
    7272    def __init__(self, title, link, description, language=None, author_email=None,
    7373            author_name=None, author_link=None, subtitle=None, categories=None,
    74             feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs):
     74            feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, stylesheets=None, **kwargs):
    7575        to_unicode = lambda s: force_unicode(s, strings_only=True)
    7676        if categories:
    7777            categories = [force_unicode(c) for c in categories]
    7878        if ttl is not None:
    7979            # Force ints to unicode
    8080            ttl = force_unicode(ttl)
     81        if stylesheets:
     82            stylesheets = [iri_to_uri(s) for s in stylesheets]
    8183        self.feed = {
    8284            'title': to_unicode(title),
    8385            'link': iri_to_uri(link),
     
    9294            'feed_copyright': to_unicode(feed_copyright),
    9395            'id': feed_guid or link,
    9496            'ttl': ttl,
     97            'stylesheets': stylesheets or (),
    9598        }
    9699        self.feed.update(kwargs)
    97100        self.items = []
     
    198201    def write(self, outfile, encoding):
    199202        handler = SimplerXMLGenerator(outfile, encoding)
    200203        handler.startDocument()
     204        for s in self.feed['stylesheets']:
     205            handler.processingInstruction('xml-stylesheet', 'type="text/css" href="%s"' % s) # http://www.w3.org/TR/xml-stylesheet/
    201206        handler.startElement(u"rss", self.rss_attributes())
    202207        handler.startElement(u"channel", self.root_attributes())
    203208        self.add_root_elements(handler)
  • django/contrib/syndication/views.py

     
    114114            feed_copyright = self.__get_dynamic_attr('feed_copyright', obj),
    115115            feed_guid = self.__get_dynamic_attr('feed_guid', obj),
    116116            ttl = self.__get_dynamic_attr('ttl', obj),
     117            stylesheets = self.__get_dynamic_attr('stylesheets', obj),
    117118            **self.feed_extra_kwargs(obj)
    118119        )
    119120
Back to Top