This pull request fixes the problem that right now, if you select
content type CDATA for atom feed like this:

  feed_entry.content('content', type="CDATA")

it raises a TypeError: Argument must be bytes or unicode, got 'dict'.
This commit is contained in:
Lars Kiesow 2016-08-28 17:54:35 +02:00
commit 4460574f30
2 changed files with 13 additions and 1 deletions

View file

@ -104,7 +104,7 @@ class FeedEntry(object):
xmlns="http://www.w3.org/1999/xhtml">%s</div>''' % \
self.__atom_content.get('content')))
elif type == 'CDATA':
content.text = etree.CDATA(self.__atom_content)
content.text = etree.CDATA(self.__atom_content.get('content'))
# Emed the text in escaped form
elif not type or type.startswith('text') or type == 'html':
content.text = self.__atom_content.get('content')

View file

@ -92,3 +92,15 @@ class TestSequenceFunctions(unittest.TestCase):
result = fg.rss_str()
assert b'domain="http://www.somedomain.com/category"' in result
def test_content_cdata_type(self):
fg = FeedGenerator()
fg.title('some title')
fg.id('http://lernfunk.de/media/654322/1')
fe = fg.add_entry()
fe.id('http://lernfunk.de/media/654322/1')
fe.title('some title')
fe.content('content', type='CDATA')
result = fg.atom_str()
assert b'<content type="CDATA"><![CDATA[content]]></content>' in result