Fix implementation of feed.getContent.
authorNeal H. Walfield <neal@walfield.org>
Sat, 10 Dec 2011 14:47:55 +0000 (14:47 +0000)
committerNeal H. Walfield <neal@walfield.org>
Sat, 10 Dec 2011 14:47:55 +0000 (14:47 +0000)
src/rss_sqlite.py

index adebe93..9cbeb82 100644 (file)
@@ -831,13 +831,18 @@ class Feed(BaseObject):
         return text
    
     def getContent(self, id):
-        contentLink = self.db.execute("SELECT contentLink FROM feed WHERE id=?;", (id,)).fetchone()[0]
+        """
+        Return the content of the article with the specified ID.  If
+        the content is not available, returns None.
+        """
+        contentLink = self.getContentLink(id)
         try:
-            file = open(self.entries[id]["contentLink"])
-            content = file.read()
-            file.close()
-        except:
-            content = "Content unavailable"
+            with open(contentLink, 'r') as file:
+                content = file.read()
+        except Exception:
+            logger.exception("Failed get content for %s: reading %s failed",
+                             id, contentLink)
+            content = None
         return content
     
     def extractDate(self, entry):