Django

Code

Changeset 5251

Show
Ignore:
Timestamp:
05/15/07 13:11:15 (1 year ago)
Author:
mtredinnick
Message:

unicode: Audited syndication framework for unicode correctness.

Files:

Legend:

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

    r5054 r5251  
    33from django.contrib.sites.models import Site 
    44from django.utils import feedgenerator 
     5from django.utils.encoding import smart_unicode 
    56from django.conf import settings 
    67 
    78def add_domain(domain, url): 
    89    if not url.startswith('http://'): 
     10        # 'url' must already be ASCII and URL-quoted, so no need for encodign 
     11        # conversions here. 
    912        url = u'http://%s%s' % (domain, url) 
    1013    return url 
     
    98101            if enc_url: 
    99102                enc = feedgenerator.Enclosure( 
    100                     url = enc_url.decode('utf-8'), 
    101                     length = str(self.__get_dynamic_attr('item_enclosure_length', item)).decode('utf-8'), 
    102                     mime_type = self.__get_dynamic_attr('item_enclosure_mime_type', item).decode('utf-8'), 
     103                    url = smart_unicode(enc_url), 
     104                    length = smart_unicode(self.__get_dynamic_attr('item_enclosure_length', item)), 
     105                    mime_type = smart_unicode(self.__get_dynamic_attr('item_enclosure_mime_type', item)) 
    103106                ) 
    104107            author_name = self.__get_dynamic_attr('item_author_name', item) 
     
    109112                author_email = author_link = None 
    110113            feed.add_item( 
    111                 title = title_tmp.render(Context({'obj': item, 'site': current_site})).decode('utf-8')
     114                title = title_tmp.render(Context({'obj': item, 'site': current_site}))
    112115                link = link, 
    113                 description = description_tmp.render(Context({'obj': item, 'site': current_site})).decode('utf-8')
     116                description = description_tmp.render(Context({'obj': item, 'site': current_site}))
    114117                unique_id = link, 
    115118                enclosure = enc, 
  • django/branches/unicode/django/utils/feedgenerator.py

    r5054 r5251  
    3535        tag = re.sub('/', ',%s:/' % date.strftime('%Y-%m-%d'), tag, 1) 
    3636    tag = re.sub('#', '/', tag) 
    37     return 'tag:' + tag 
     37    return u'tag:' + tag 
    3838 
    3939class SyndicationFeed(object):