annotate AddFeed.py @ 226:016c89dfd488

use our generic PyQtLib instead of custom Qt models in this project
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 22 May 2014 06:10:05 +0200
parents 699d8f1cebd4
children 3ce39af93e77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
bb3c851b18b1 add source file endcoding header
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 123
diff changeset
1 # -*- coding: utf-8 -*-
218
699d8f1cebd4 unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
2 from PyQt4.QtGui import QDialog
27
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3 from Ui_AddFeed import Ui_AddFeed
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
4 import logging
27
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5
218
699d8f1cebd4 unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
6 class AddFeed(QDialog):
121
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 58
diff changeset
7 def __init__(self, backend=None):
218
699d8f1cebd4 unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
8 super(AddFeed, self).__init__(None)
121
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 58
diff changeset
9 self.backend = backend
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
10 self.exception = None
27
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 self.ui = Ui_AddFeed()
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 self.ui.setupUi(self)
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 self.ui.url.setFocus()
121
510a5d00e98a re-enabled AddFeed - does not work yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 58
diff changeset
14
49
6eba4168fd54 move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 27
diff changeset
15 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
16 try:
123
862760b161b4 restructured adding a feed so that only the URL is passed into the backend - the rest of the operation is backend-internal
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 121
diff changeset
17 url = self.getUrl()
862760b161b4 restructured adding a feed so that only the URL is passed into the backend - the rest of the operation is backend-internal
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 121
diff changeset
18 self.backend.createFeed(url)
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
19 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
20 logging.getLogger("AddFeed").info(ae)
218
699d8f1cebd4 unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
21 self.exception = ae
699d8f1cebd4 unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
22 super(AddFeed, self).accept()
49
6eba4168fd54 move the logic to add a feed into AddFeed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 27
diff changeset
23
27
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
24 def getUrl(self):
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
25 text = self.ui.url.text()
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
26 # the content of a QLineEdit is a QString, convert it to a Python string
bdd1296a4b8c implemented adding a feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
27 return str(text)