Mercurial > hg > Feedworm
comparison 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 |
comparison
equal
deleted
inserted
replaced
118:0e73adb2dec4 | 119:04a730f9d07d |
---|---|
1 | |
2 from Preferences import Preferences | |
3 import Database | |
4 import logging | |
5 import util | |
6 import FeedList | |
7 | |
8 class SqlAlchemyBackend(object): | |
9 ''' | |
10 Backend that uses sqlalchemy for persistence | |
11 ''' | |
12 | |
13 def __init__(self): | |
14 self._initLogging() | |
15 self.session = Database.createSession() | |
16 self.prefs = Preferences(self.session) | |
17 | |
18 def _initLogging(self): | |
19 logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN) | |
20 | |
21 sqlalchemyLogLevel = logging.ERROR | |
22 if util.databaseLoggingEnabled(): | |
23 sqlalchemyLogLevel = logging.INFO | |
24 logging.getLogger("sqlalchemy").setLevel(sqlalchemyLogLevel) | |
25 | |
26 def preferences(self): | |
27 return self.prefs | |
28 | |
29 def getFeeds(self): | |
30 return FeedList.getFeeds(self.session) | |
31 | |
32 def dispose(self): | |
33 # save all uncommitted state, just in case | |
34 self.session.commit() |