Code

Ticket #9800: rss-guid_is_permalink-attribute.diff

File rss-guid_is_permalink-attribute.diff, 2.2 KB (added by andreiko, 4 years ago)

my version of patch

Line 
1Index: django/utils/feedgenerator.py
2===================================================================
3--- django/utils/feedgenerator.py       (revision 14464)
4+++ django/utils/feedgenerator.py       (working copy)
5@@ -71,7 +71,7 @@
6     "Base class for all syndication feeds. Subclasses should provide write()"
7     def __init__(self, title, link, description, language=None, author_email=None,
8             author_name=None, author_link=None, subtitle=None, categories=None,
9-            feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs):
10+            feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, guid_is_permalink=None, **kwargs):
11         to_unicode = lambda s: force_unicode(s, strings_only=True)
12         if categories:
13             categories = [force_unicode(c) for c in categories]
14@@ -92,6 +92,7 @@
15             'feed_copyright': to_unicode(feed_copyright),
16             'id': feed_guid or link,
17             'ttl': ttl,
18+            'guid_is_permalink': guid_is_permalink,
19         }
20         self.feed.update(kwargs)
21         self.items = []
22@@ -264,7 +265,10 @@
23         if item['comments'] is not None:
24             handler.addQuickElement(u"comments", item['comments'])
25         if item['unique_id'] is not None:
26-            handler.addQuickElement(u"guid", item['unique_id'])
27+            guid_attrs = {}
28+            if isinstance(self.feed['guid_is_permalink'], bool):
29+                guid_attrs['isPermalink'] = str(self.feed['guid_is_permalink']).lower()
30+            handler.addQuickElement(u"guid", item['unique_id'], guid_attrs)
31         if item['ttl'] is not None:
32             handler.addQuickElement(u"ttl", item['ttl'])
33 
34Index: django/contrib/syndication/views.py
35===================================================================
36--- django/contrib/syndication/views.py (revision 14464)
37+++ django/contrib/syndication/views.py (working copy)
38@@ -118,6 +118,7 @@
39             feed_copyright = self.__get_dynamic_attr('feed_copyright', obj),
40             feed_guid = self.__get_dynamic_attr('feed_guid', obj),
41             ttl = self.__get_dynamic_attr('ttl', obj),
42+            guid_is_permalink = self.__get_dynamic_attr('guid_is_permalink', obj),
43             **self.feed_extra_kwargs(obj)
44         )
45