Mercurial > hg > Feedworm
annotate AddFeed.py @ 76:f909550683b0
some links/ids can be very long. give the link/id column more space
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 11 Aug 2010 03:59:33 +0200 |
parents | dcee24702dd7 |
children | 510a5d00e98a |
rev | line source |
---|---|
27 | 1 |
2 from PyQt4 import QtGui | |
3 from Ui_AddFeed import Ui_AddFeed | |
49
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
4 import FeedUpdater |
58
dcee24702dd7
Adding a feed now logs the exception if one occurred during retrieval. More normalization of feed entries before creating new FeedEntry objects.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
50
diff
changeset
|
5 import logging |
27 | 6 |
7 class AddFeed(QtGui.QDialog): | |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
49
diff
changeset
|
8 def __init__(self, session): |
27 | 9 QtGui.QWidget.__init__(self, None) |
10 self.session = session | |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
49
diff
changeset
|
11 self.exception = None |
27 | 12 self.ui = Ui_AddFeed() |
13 self.ui.setupUi(self) | |
14 self.ui.url.setFocus() | |
15 | |
49
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
16 def accept(self): |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
49
diff
changeset
|
17 try: |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
49
diff
changeset
|
18 self.createFeed() |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
49
diff
changeset
|
19 self.session.commit() |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
49
diff
changeset
|
20 except AttributeError as ae: |
58
dcee24702dd7
Adding a feed now logs the exception if one occurred during retrieval. More normalization of feed entries before creating new FeedEntry objects.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
50
diff
changeset
|
21 logging.getLogger("AddFeed").info(ae) |
dcee24702dd7
Adding a feed now logs the exception if one occurred during retrieval. More normalization of feed entries before creating new FeedEntry objects.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
50
diff
changeset
|
22 |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
49
diff
changeset
|
23 self.exception = ae |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
49
diff
changeset
|
24 self.session.rollback() |
49
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
25 QtGui.QDialog.accept(self) |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
26 |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
27 def createFeed(self): |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
28 url = self.getUrl() |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
29 # TODO get status from feedUpdater and display in status area of the main window |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
30 FeedUpdater.createNewFeed(url, self.session) |
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
31 |
27 | 32 def getUrl(self): |
33 text = self.ui.url.text() | |
34 # the content of a QLineEdit is a QString, convert it to a Python string | |
35 return str(text) | |
49
6eba4168fd54
move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
27
diff
changeset
|
36 |