Mercurial > hg > Feedworm
diff feedupdate-main.py @ 12:9ede118b93ef
move session creation into its own module
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 28 Apr 2010 02:09:48 +0200 |
parents | e87c54b3a216 |
children | 591ecc2a99bd |
line wrap: on
line diff
--- a/feedupdate-main.py Tue Apr 27 20:18:22 2010 +0200 +++ b/feedupdate-main.py Wed Apr 28 02:09:48 2010 +0200 @@ -1,24 +1,12 @@ #!/usr/bin/env python -from ConfigParser import ConfigParser +from database import createSession from Feed import Feed from FeedUpdater import updateAllFeeds -import Mapping import logging -import socket -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker logger = logging.getLogger("feedupdater") -def loadDatabaseProperties(): - hostname = socket.gethostname() - filename = "database-%s.ini" % hostname - - parser = ConfigParser(); - parser.read(filename) - return parser.get("database", "url") - def createFeed(session): if len(session.query(Feed).all()) == 0: newFeed = Feed("Joel on Software", "http://www.joelonsoftware.com/rss.xml") @@ -33,11 +21,7 @@ print entry.title if __name__ == "__main__": - databaseUrl = loadDatabaseProperties() - engine = create_engine(databaseUrl,echo=True) - Mapping.createMapping(engine) - SessionMaker = sessionmaker(bind = engine) - session = SessionMaker() + session = createSession() createFeed(session) updateAllFeeds(session)