当前位置: 首页>>代码示例>>Python>>正文


Python Book.get_book方法代码示例

本文整理汇总了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')
开发者ID:wiltzius,项目名称:btp-lemur,代码行数:12,代码来源:views.py

示例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()
开发者ID:wiltzius,项目名称:btp-lemur,代码行数:15,代码来源:views.py


注:本文中的models.Book.get_book方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。