# HG changeset patch # User Dirk Olmes # Date 1272307597 -7200 # Node ID bfd47f55d85b514497fb595eb341a00afc8e7b4e # Parent e0199f3834428ee4211a3b1a0de88ebca50623d5 add the updated date of the feed diff -r e0199f383442 -r bfd47f55d85b FeedEntry.py --- a/FeedEntry.py Mon Apr 26 19:33:07 2010 +0200 +++ b/FeedEntry.py Mon Apr 26 20:46:37 2010 +0200 @@ -5,11 +5,8 @@ result = session.query(FeedEntry).filter(FeedEntry.id == id) return result.first() - def __init__(self, id, url, title, summary): - self.id = id - self.url = url - self.title = title - self.summary = summary + def __init__(self): + pass def __repr__(self): return "" % (self.pk, self.link) diff -r e0199f383442 -r bfd47f55d85b FeedUpdater.py --- a/FeedUpdater.py Mon Apr 26 19:33:07 2010 +0200 +++ b/FeedUpdater.py Mon Apr 26 20:46:37 2010 +0200 @@ -1,4 +1,5 @@ +from datetime import datetime from Feed import Feed from FeedEntry import FeedEntry import feedparser @@ -25,6 +26,11 @@ self.createFeedEntry(entry) def createFeedEntry(self, entry): - newEntry = FeedEntry(id=entry.id, url=entry.link, title=entry.title, summary=entry.summary) - newEntry.feed = self.feed - self.session.add(newEntry) + new = FeedEntry() + new.id = entry.id + new.link = entry.link + new.title = entry.title + new.updated = datetime(*entry.updated_parsed[:6]) + new.summary = entry.summary + new.feed = self.feed + self.session.add(new) diff -r e0199f383442 -r bfd47f55d85b Mapping.py --- a/Mapping.py Mon Apr 26 19:33:07 2010 +0200 +++ b/Mapping.py Mon Apr 26 20:46:37 2010 +0200 @@ -2,6 +2,7 @@ from Feed import Feed from FeedEntry import FeedEntry from sqlalchemy import Column +from sqlalchemy import DateTime from sqlalchemy import ForeignKey from sqlalchemy import Integer from sqlalchemy import MetaData @@ -22,9 +23,10 @@ feedEntryTable = Table("feed_entry", metadata, Column("pk", Integer, primary_key=True), Column("id", String(255), nullable=False), - Column("url", String(255), nullable=False), + Column("link", String(255), nullable=False), Column("title", String, nullable=False), Column("summary", String, nullable=False), + Column("updated", DateTime), Column("feed_id", Integer, ForeignKey("feed.pk")) ) diff -r e0199f383442 -r bfd47f55d85b feedupdate-main.py --- a/feedupdate-main.py Mon Apr 26 19:33:07 2010 +0200 +++ b/feedupdate-main.py Mon Apr 26 20:46:37 2010 +0200 @@ -17,9 +17,10 @@ return parser.get("database", "url") def createFeed(session): - newFeed = Feed("Joel on Software", "http://www.joelonsoftware.com/rss.xml") - session.add(newFeed) - session.commit() + if len(session.query(Feed).all()) == 0: + newFeed = Feed("Joel on Software", "http://www.joelonsoftware.com/rss.xml") + session.add(newFeed) + session.commit() def listFeeds(session): allFeeds = session.query(Feed) @@ -36,5 +37,5 @@ session = SessionMaker() #createFeed(session) - updateAllFeeds(session) - #listFeeds(session) + #updateAllFeeds(session) + listFeeds(session)