Mercurial > hg > Feedworm
comparison backend/sqlalchemy/SqlAlchemyBackend.py @ 154:2682db280be0
reorder methods
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sat, 27 Aug 2011 07:32:01 +0200 |
parents | 65c4bb6d5add |
children | a05719a6175e |
comparison
equal
deleted
inserted
replaced
153:65c4bb6d5add | 154:2682db280be0 |
---|---|
34 sqlalchemyLogLevel = logging.INFO | 34 sqlalchemyLogLevel = logging.INFO |
35 logging.getLogger("sqlalchemy").setLevel(sqlalchemyLogLevel) | 35 logging.getLogger("sqlalchemy").setLevel(sqlalchemyLogLevel) |
36 | 36 |
37 def preferences(self): | 37 def preferences(self): |
38 return self.prefs | 38 return self.prefs |
39 | |
40 def dispose(self): | |
41 # save all uncommitted state, just in case | |
42 self.session.commit() | |
43 self.session.close() | |
39 | 44 |
40 # | 45 # |
41 # handling of feeds | 46 # handling of feeds |
42 # | 47 # |
43 | 48 |
76 | 81 |
77 def deleteSelectedFeed(self): | 82 def deleteSelectedFeed(self): |
78 self.session.delete(self.selectedFeed) | 83 self.session.delete(self.selectedFeed) |
79 self.session.commit() | 84 self.session.commit() |
80 | 85 |
86 def createFeed(self, url): | |
87 try: | |
88 FeedUpdater.createNewFeed(url, self.session) | |
89 self.session.commit() | |
90 except AttributeError as ae: | |
91 self.session.rollback() | |
92 raise ae | |
93 | |
94 def updateAllFeeds(self): | |
95 FeedUpdater.updateAllFeeds(self.session) | |
96 self.session.commit() | |
97 | |
98 def updateFeed(self, feed, changes): | |
99 feed.takeChangesFrom(changes) | |
100 feed.incrementNextUpdateDate() | |
101 self.session.commit() | |
102 | |
81 # | 103 # |
82 # handling of the selected feed entry | 104 # handling of the selected feed entry |
83 # | 105 # |
84 def selectFeedEntry(self, index): | 106 def selectFeedEntry(self, index): |
85 self.selectedFeedEntry = self.feedEntries[index] | 107 self.selectedFeedEntry = self.feedEntries[index] |
94 def toggleSelectedFeedEntryRead(self): | 116 def toggleSelectedFeedEntryRead(self): |
95 self.selectedFeedEntry.toggleRead() | 117 self.selectedFeedEntry.toggleRead() |
96 self.session.commit() | 118 self.session.commit() |
97 | 119 |
98 | 120 |
99 | |
100 def createFeed(self, url): | |
101 try: | |
102 FeedUpdater.createNewFeed(url, self.session) | |
103 self.session.commit() | |
104 except AttributeError as ae: | |
105 self.session.rollback() | |
106 raise ae | |
107 | |
108 def updateFeed(self, feed, changes): | |
109 feed.takeChangesFrom(changes) | |
110 feed.incrementNextUpdateDate() | |
111 self.session.commit() | |
112 | |
113 | |
114 | |
115 def updateAllFeeds(self): | |
116 FeedUpdater.updateAllFeeds(self.session) | |
117 self.session.commit() | |
118 | |
119 def expireFeedEntries(self): | 121 def expireFeedEntries(self): |
120 logger = logging.getLogger("feedupdater") | 122 logger = logging.getLogger("feedupdater") |
121 expireDate = self._calculateExpireDate() | 123 expireDate = self._calculateExpireDate() |
122 logger.info("expiring entries older than " + str(expireDate)) | 124 logger.info("expiring entries older than " + str(expireDate)) |
123 feedEntry = Mapping.feedEntryTable | 125 feedEntry = Mapping.feedEntryTable |
130 def _calculateExpireDate(self): | 132 def _calculateExpireDate(self): |
131 now = datetime.now() | 133 now = datetime.now() |
132 daysToKeepFeedEntries = self.prefs.daysToKeepFeedEntries() | 134 daysToKeepFeedEntries = self.prefs.daysToKeepFeedEntries() |
133 delta = timedelta(days=daysToKeepFeedEntries) | 135 delta = timedelta(days=daysToKeepFeedEntries) |
134 return now - delta | 136 return now - delta |
135 | |
136 def dispose(self): | |
137 # save all uncommitted state, just in case | |
138 self.session.commit() | |
139 self.session.close() |