diff options
author | cedricbonhomme <devnull@localhost> | 2010-12-03 08:07:04 +0100 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2010-12-03 08:07:04 +0100 |
commit | 856d20fb57f787448742dc5eb9123bc397e22bd3 (patch) | |
tree | 3bf722b06a3c8dc5b308e11a966705e40a32eb3b | |
parent | Updated code for new data structure. #3 (diff) | |
download | newspipe-856d20fb57f787448742dc5eb9123bc397e22bd3.tar.gz newspipe-856d20fb57f787448742dc5eb9123bc397e22bd3.tar.bz2 newspipe-856d20fb57f787448742dc5eb9123bc397e22bd3.zip |
Updated code for new data structure. #4
-rwxr-xr-x | pyAggr3g470r.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index f92407d3..5bbc83fe 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -1019,19 +1019,21 @@ class Root: """ try: feed_id, article_id = param.split(':') + except: + return self.error_page("Bad URL.") + try: feed = self.feeds[feed_id] + article = feed.articles[article_id] except: - return self.error_page("This article do not exists.") - for article in feed.articles: - if article_id == article.article_id: - try: - conn = sqlite3.connect(utils.sqlite_base, isolation_level = None) - c = conn.cursor() - c.execute("DELETE FROM articles WHERE article_link='" + article.article_link +"'") - conn.commit() - c.close() - except Exception, e: - return e + self.error_page("This article do not exists.") + try: + conn = sqlite3.connect(utils.sqlite_base, isolation_level = None) + c = conn.cursor() + c.execute("DELETE FROM articles WHERE article_link='" + article.article_link +"'") + conn.commit() + c.close() + except Exception, e: + return e return self.index() delete_article.exposed = True @@ -1149,24 +1151,22 @@ class Root: try: feed_id, article_id = param.split(':') except: - return self.error_page("Bad URL") + return self.error_page("Bad URL.") try: feed = self.feeds[feed_id] - except KeyError: - return self.error_page("This feed do not exists.") + article = feed.articles[article_id] + except: + self.error_page("This article do not exists.") try: folder = utils.path + "/var/export/epub/" os.makedirs(folder) except OSError: return self.error_page(utils.path + "var/export/epub/"+" already exists.\nYou should delete this folder.") - for article in feed.articles: - if article_id == article.article_id: - section = ez_epub.Section() - section.title = article.article_title - section.paragraphs = [utils.clear_string(article.article_description)] - ez_epub.makeBook(article.article_title, [feed.feed_title], [section], \ - os.path.normpath(folder + "article"), lang='en-US', cover=None) - break + section = ez_epub.Section() + section.title = article.article_title + section.paragraphs = [utils.clear_string(article.article_description)] + ez_epub.makeBook(article.article_title, [feed.feed_title], [section], \ + os.path.normpath(folder + "article"), lang='en-US', cover=None) return self.description(param) epub.exposed = True |