IGN:Speed up book deletion from the database and update Physics Today recipe

This commit is contained in:
Kovid Goyal 2009-02-19 13:57:49 -08:00
parent 94d0473c97
commit 4d150760d3
3 changed files with 10 additions and 8 deletions

View File

@ -216,12 +216,9 @@ class BooksModel(QAbstractTableModel):
def delete_books(self, indices):
ids = [ self.id(i) for i in indices ]
ids = map(self.id, indices)
for id in ids:
row = self.db.index(id)
self.beginRemoveRows(QModelIndex(), row, row)
self.db.delete_book(id)
self.endRemoveRows()
self.db.delete_book(id, notify=False)
self.count_changed()
self.clear_caches()
self.reset()

View File

@ -729,7 +729,7 @@ class LibraryDatabase2(LibraryDatabase):
if notify:
self.notify('metadata', [id])
def delete_book(self, id):
def delete_book(self, id, notify=True):
'''
Removes book from the result cache and the underlying database.
'''
@ -744,7 +744,8 @@ class LibraryDatabase2(LibraryDatabase):
self.conn.commit()
self.clean()
self.data.books_deleted([id])
self.notify('delete', [id])
if notify:
self.notify('delete', [id])
def remove_format(self, index, format, index_is_id=False, notify=True):
id = index if index_is_id else self.id(index)

View File

@ -1,5 +1,6 @@
import re
from calibre.web.feeds.news import BasicNewsRecipe
from calibre import strftime
class Physicstoday(BasicNewsRecipe):
title = u'Physicstoday'
@ -8,6 +9,7 @@ class Physicstoday(BasicNewsRecipe):
publisher = 'American Institute of Physics'
category = 'Physics'
language = _('English')
cover_url = strftime('http://ptonline.aip.org/journals/doc/PHTOAD-home/jrnls/images/medcover%m_%Y.jpg')
oldest_article = 30
max_articles_per_feed = 100
no_stylesheets = True
@ -17,8 +19,10 @@ class Physicstoday(BasicNewsRecipe):
remove_tags_before = dict(name='h1')
remove_tags = [dict(name='div', attrs={'class':'highslide-footer'})]
remove_tags = [dict(name='div', attrs={'class':'highslide-header'})]
#remove_tags = [dict(name='a', attrs={'class':'highslide'})]
preprocess_regexps = [
(re.compile(r'<!--start PHTOAD_tail.jsp -->.*</body>', re.DOTALL|re.IGNORECASE),
#(re.compile(r'<!--start PHTOAD_tail.jsp -->.*</body>', re.DOTALL|re.IGNORECASE),
(re.compile(r'<!-- END ARTICLE and footer section -->.*</body>', re.DOTALL|re.IGNORECASE),
lambda match: '</body>'),
]