Mercurial > hg > Feedworm
comparison AddFeed.py @ 50:4b0d686493fb
better error handling while adding feeds: data is only saved if a feed could be created and entries could be retrieved. MainWindow displays feedback in the status bar if an exception occurred while adding a feed.
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Mon, 17 May 2010 04:30:55 +0200 |
parents | 6eba4168fd54 |
children | dcee24702dd7 |
comparison
equal
deleted
inserted
replaced
49:6eba4168fd54 | 50:4b0d686493fb |
---|---|
2 from PyQt4 import QtGui | 2 from PyQt4 import QtGui |
3 from Ui_AddFeed import Ui_AddFeed | 3 from Ui_AddFeed import Ui_AddFeed |
4 import FeedUpdater | 4 import FeedUpdater |
5 | 5 |
6 class AddFeed(QtGui.QDialog): | 6 class AddFeed(QtGui.QDialog): |
7 def __init__(self, session=None): | 7 def __init__(self, session): |
8 QtGui.QWidget.__init__(self, None) | 8 QtGui.QWidget.__init__(self, None) |
9 self.session = session | 9 self.session = session |
10 self.exception = None | |
10 self.ui = Ui_AddFeed() | 11 self.ui = Ui_AddFeed() |
11 self.ui.setupUi(self) | 12 self.ui.setupUi(self) |
12 self.ui.url.setFocus() | 13 self.ui.url.setFocus() |
13 | 14 |
14 def accept(self): | 15 def accept(self): |
15 self.createFeed() | 16 try: |
17 self.createFeed() | |
18 self.session.commit() | |
19 except AttributeError as ae: | |
20 self.exception = ae | |
21 self.session.rollback() | |
16 QtGui.QDialog.accept(self) | 22 QtGui.QDialog.accept(self) |
17 | 23 |
18 def createFeed(self): | 24 def createFeed(self): |
19 url = self.getUrl() | 25 url = self.getUrl() |
20 # TODO get status from feedUpdater and display in status area of the main window | 26 # TODO get status from feedUpdater and display in status area of the main window |