view 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 source

#!/usr/bin/env python

from database import createSession
from Feed import Feed
from FeedUpdater import updateAllFeeds
import logging

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__":
    session = createSession()
    
    createFeed(session)
    updateAllFeeds(session)
    #listFeeds(session)