Mercurial > hg > Feedworm
comparison backend/sqlalchemy/SqlAlchemyBackend.py @ 123:862760b161b4 backend
restructured adding a feed so that only the URL is passed into the backend - the rest of the operation is backend-internal
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Mon, 22 Aug 2011 10:30:33 +0200 |
parents | f5afe0c1f4d2 |
children | a4b2077c9603 |
comparison
equal
deleted
inserted
replaced
122:f5afe0c1f4d2 | 123:862760b161b4 |
---|---|
1 | 1 |
2 from Preferences import Preferences | 2 from Preferences import Preferences |
3 from FeedUpdater import FeedUpdater | |
4 import Database | 3 import Database |
4 import FeedList | |
5 import FeedUpdater | |
5 import logging | 6 import logging |
6 import util | 7 import util |
7 import FeedList | |
8 | 8 |
9 class SqlAlchemyBackend(object): | 9 class SqlAlchemyBackend(object): |
10 ''' | 10 ''' |
11 Backend that uses sqlalchemy for persistence | 11 Backend that uses sqlalchemy for persistence |
12 ''' | 12 ''' |
26 logging.getLogger("sqlalchemy").setLevel(sqlalchemyLogLevel) | 26 logging.getLogger("sqlalchemy").setLevel(sqlalchemyLogLevel) |
27 | 27 |
28 def preferences(self): | 28 def preferences(self): |
29 return self.prefs | 29 return self.prefs |
30 | 30 |
31 def feedUpdater(self): | |
32 if self.updater is None: | |
33 self.updater = FeedUpdater(self.session) | |
34 return self.updater | |
35 | |
36 def getFeeds(self): | 31 def getFeeds(self): |
37 return FeedList.getFeeds(self.session) | 32 return FeedList.getFeeds(self.session) |
38 | 33 |
39 def toggleRead(self, feedEntry): | 34 def toggleRead(self, feedEntry): |
40 feedEntry.toggleRead() | 35 feedEntry.toggleRead() |
42 | 37 |
43 def markAllEntriesRead(self, feed): | 38 def markAllEntriesRead(self, feed): |
44 feed.markAllEntriesRead() | 39 feed.markAllEntriesRead() |
45 self.session.commit() | 40 self.session.commit() |
46 | 41 |
42 def createFeed(self, url): | |
43 try: | |
44 FeedUpdater.createNewFeed(url, self.session) | |
45 self.session.commit() | |
46 except AttributeError as ae: | |
47 self.session.rollback() | |
48 raise ae | |
49 | |
47 def dispose(self): | 50 def dispose(self): |
48 # save all uncommitted state, just in case | 51 # save all uncommitted state, just in case |
49 self.session.commit() | 52 self.session.commit() |