def lookup_book(book_id, id_type): try: e = lookup(book_id, id_type) if e != None: b = Book() b.fromxml(e) return b else: return None except ValueError: return None
def migrate(self): xml = lookup(self.asin,"ASIN") if xml != None: self.fromxml(xml) self.save()