Per RSS 2.0 Specification (http://blogs.law.harvard.edu/tech/rss) I've added categories to post items.
SyndicationFeed.add_item() can accept kw-parameter 'category', which can be a unicode string or a list of unicode strings. Rss201rev2Feed uses it to generate one or multiple <category> tags per item.
Index: feedgenerator.py
===================================================================
--- feedgenerator.py (revision 640)
+++ feedgenerator.py (working copy)
@@ -33,7 +33,7 @@
def add_item(self, title, link, description, author_email=None,
author_name=None, pubdate=None, comments=None, unique_id=None,
- enclosure=None):
+ enclosure=None, category=None):
"""
Adds an item to the feed. All args are expected to be Python Unicode
objects except pubdate, which is a datetime.datetime object, and
@@ -49,6 +49,7 @@
'comments': comments,
'unique_id': unique_id,
'enclosure': enclosure,
+ 'category': category,
})
def num_items(self):
@@ -142,6 +143,12 @@
handler.addQuickElement(u"enclosure", '',
{u"url": item['enclosure'].url, u"length": item['enclosure'].length,
u"type": item['enclosure'].mime_type})
+ if item['category'] is not None:
+ if isinstance(item['category'], list):
+ for cat in item['category']:
+ handler.addQuickElement(u"category", cat, {})
+ else:
+ handler.addQuickElement(u"category", item['category'], {})
handler.endElement(u"item")
# This isolates the decision of what the system default is, so calling code can