comparison 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
comparison
equal deleted inserted replaced
33:f371d02fa09d 34:5813e3c10f14
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import Database
3 from Feed import Feed 4 from Feed import Feed
4 from FeedUpdater import updateAllFeeds 5 from FeedUpdater import updateAllFeeds
5 import logging 6 import logging
6 from util import configureLogging, createSession 7 import util
7 8
8 logger = logging.getLogger("feedupdater") 9 logger = logging.getLogger("feedupdater")
9 10
10 def createFeed(session): 11 def createFeed(session):
11 if len(session.query(Feed).all()) == 0: 12 if len(session.query(Feed).all()) == 0:
19 logger.info("feed: " + feed.name) 20 logger.info("feed: " + feed.name)
20 for entry in feed.entries: 21 for entry in feed.entries:
21 print entry.title 22 print entry.title
22 23
23 if __name__ == "__main__": 24 if __name__ == "__main__":
24 configureLogging() 25 util.configureLogging()
25 session = createSession() 26 session = Database.createSession()
26 27
27 createFeed(session) 28 #createFeed(session)
28 updateAllFeeds(session) 29 #updateAllFeeds(session)
29 #listFeeds(session) 30 #listFeeds(session)
31 #session.close()