same optimization in librarything loader

pull/1/head
eric 2011-12-22 14:51:12 -05:00
parent 68d6ef93fd
commit a931b9d2b3
1 changed files with 4 additions and 2 deletions

View File

@ -211,14 +211,16 @@ def load_librarything_into_wishlist(user, lt_username, max_books=None):
logger.info("%d %s %s", i, book["title"]["title"], isbn)
try:
edition = bookloader.add_by_isbn(isbn)
if not edition:
continue
# add the librarything ids to the db since we know them now
edition.librarything_id = book['book_id']
edition.save()
edition.work.librarything_id = book['work_id']
edition.work.save()
regluit.core.tasks.populate_edition.delay(edition)
user.wishlist.add_work(edition.work, 'librarything')
if edition.new:
regluit.core.tasks.populate_edition.delay(edition)
logger.info("Work with isbn %s added to wishlist.", isbn)
except Exception, e:
logger.info ("error adding ISBN %s: %s", isbn, e)