Mercurial > hg > Feedworm
view feedupdate-main.py @ 34:5813e3c10f14
move the database logic out into its own module. Make everything reload safe so that multiple sessions can be created from interactive sessions
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 05 May 2010 02:14:05 +0200 |
parents | 42a225be7e56 |
children | aaec263f07ca |
line wrap: on
line source
#!/usr/bin/env python import Database from Feed import Feed from FeedUpdater import updateAllFeeds import logging import util logger = logging.getLogger("feedupdater") def createFeed(session): 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) for feed in allFeeds: logger.info("feed: " + feed.name) for entry in feed.entries: print entry.title if __name__ == "__main__": util.configureLogging() session = Database.createSession() #createFeed(session) #updateAllFeeds(session) #listFeeds(session) #session.close()