本文整理汇总了Python中models.Book.get_book方法的典型用法代码示例。如果您正苦于以下问题:Python Book.get_book方法的具体用法?Python Book.get_book怎么用?Python Book.get_book使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Book
的用法示例。
在下文中一共展示了Book.get_book方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: order_add_book_asin
# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get_book [as 别名]
def order_add_book_asin(request):
"""Adds a book with the ASIN passed via POST. Used for AJAX book adds of
books that were found in Amazon"""
try:
book = Book.get_book(request.POST['ASIN'])
order_add_book(request, book)
return order_render_as_response(request)
except amazonproduct.InvalidParameterValue:
# this ASIN isn't found, so return 404-not-found error message
raise Http404('No book with that ASIN found on Amazon')
示例2: order_add_book_isbn
# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get_book [as 别名]
def order_add_book_isbn(request):
"""Same as order_add_book_asin except it does additional ISBN format checking"""
if (isbn.isValid(isbn.isbn_strip(request.POST['ISBN']))):
try:
book = Book.get_book(isbn.isbn_strip(request.POST['ISBN']))
order_add_book(request, book)
return order_render_as_response(request)
except amazonproduct.InvalidParameterValue:
# this ASIN isn't found, so return 404-not-found error message
raise Http404('No book with that ISBN found on Amazon')
else:
# this ASIN isn't well-formatted, so return 400-bad-request error message
return HttpResponseBadRequest()