Mercurial > hg > Feedworm
view util.py @ 54:b535bce50626
the relationship between feed and its entries can be mapped as lazy -> fewer DB round trips
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Tue, 18 May 2010 03:12:00 +0200 |
parents | 03358c113170 |
children | 254d5b89a6ca |
line wrap: on
line source
from datetime import datetime, timedelta from Feed import Feed import logging logger = logging.getLogger("database") def configureLogging(): logging.basicConfig(level=logging.DEBUG) logging.getLogger("sqlalchemy").setLevel(logging.INFO) logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN) def loadFeeds(session=None, filename="feeds.txt"): file = open(filename) for line in file: (title, rss_url) = line.split("|") # remove the newline rss_url = rss_url.rstrip() feed = Feed(title, rss_url) session.add(feed) file.close() session.commit() def forceUpdateAllFeeds(session=None): for feed in Feed.all(session): feed.next_update = datetime.now() - timedelta(minutes=1) session.commit() def str2bool(string): return string.lower() in ["yes", "true", "t", "1"] def bool2str(bool): if bool: return "True" else: return "False"