Mercurial > hg > Feedworm
diff backend/sqlalchemy/SqlAlchemyBackend.py @ 119:04a730f9d07d backend
move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sun, 21 Aug 2011 03:55:16 +0200 |
parents | |
children | 510a5d00e98a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/backend/sqlalchemy/SqlAlchemyBackend.py Sun Aug 21 03:55:16 2011 +0200 @@ -0,0 +1,34 @@ + +from Preferences import Preferences +import Database +import logging +import util +import FeedList + +class SqlAlchemyBackend(object): + ''' + Backend that uses sqlalchemy for persistence + ''' + + def __init__(self): + self._initLogging() + self.session = Database.createSession() + self.prefs = Preferences(self.session) + + def _initLogging(self): + logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN) + + sqlalchemyLogLevel = logging.ERROR + if util.databaseLoggingEnabled(): + sqlalchemyLogLevel = logging.INFO + logging.getLogger("sqlalchemy").setLevel(sqlalchemyLogLevel) + + def preferences(self): + return self.prefs + + def getFeeds(self): + return FeedList.getFeeds(self.session) + + def dispose(self): + # save all uncommitted state, just in case + self.session.commit()