Commits

Anonymous committed b12a04d

improved importing of ZXA feeds (importers import the correct
syntax instead of HTML now). This fixes #137.

Comments (0)

Files changed (3)

 - importer no longer creates new users if a user was selected in the
   dropdown.
 - fixed importing of ZXA feeds with tags.
+- improved importing of ZXA feeds (importers import the correct
+  syntax instead of HTML now)
 - fixed wrong content type exporting in ZXA feeds.
 - fixed bug in tag-cloud query.  Too many items were counted for
   each tag.

zine/importers/__init__.py

                     old_post.pings_enabled, parser=old_post.parser,
                     uid=old_post.uid)
         if old_post.parser_data is not None:
-            post.parser_data = old_post.parser_data
+            post.parser_data.clear()
+            post.parser_data.update(old_post.parser_data)
         yield u'<li><strong>%s</strong>' % escape(post.title)
 
         for tag in old_post.tags:

zine/importers/feed.py

 xml = Namespace(XML_NS)
 
 
-def _get_text_content(elements):
+def _get_text_content(elements, fallback=True):
     """Return the text content from the best element match."""
-    if not elements:
-        return u''
     for element in elements:
         if element.attrib.get('type') == 'text':
             return element.text or u''
-    for element in elements:
-        if element.attrib.get('type') == 'html':
-            return to_text(element)
-    return to_text(elements[0])
+    if fallback:
+        if not elements:
+            return u''
+        for element in elements:
+            if element.attrib.get('type') == 'html':
+                return to_text(element)
+        return to_text(elements[0])
 
 
 def _get_html_content(elements):
         author = self._authors.get(dependency)
         if author is None:
             element = self._lookup_user(self._dependencies,
-                                        id=dependency)[0]
+                                        id=str(dependency))[0]
             author = Author(
                 element.findtext(zine.username),
                 element.findtext(zine.email),
             blog.element.find(zine.configuration)))
 
     def postprocess_post(self, post):
+        post.parser_data = _parser_data(post.element.findtext(zine.parser_data))
+        content = _get_text_content(post.element.findall(atom.content),
+                                    fallback=False)
+        if content is not None:
+            post.body = content
         content_type = post.element.findtext(zine.content_type)
         if content_type is not None:
             post.content_type = content_type
             author = element.find(zine.author)
             dependency = author.attrib.get('dependency')
             if dependency is not None:
-                author = self._get_author(author)
+                author = self._get_author(dependency)
                 email = www = None
             else:
                 email = author.findtext(zine.email)