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


Python Book.get方法代码示例

本文整理汇总了Python中models.Book.get方法的典型用法代码示例。如果您正苦于以下问题:Python Book.get方法的具体用法?Python Book.get怎么用?Python Book.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Book的用法示例。


在下文中一共展示了Book.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: content

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get [as 别名]
def content(bid, cid):
    book = Book.get(bid)
    chapter = Chapter.get(cid, bid)
    if not (book and chapter):
        abort(404)

    # NOTE read/set cookies for recent reading
    recent_reading = request.cookies.get('recent_reading')
    rec_book_chapters = []
    if recent_reading:
        for bid_cid in recent_reading.split('|'):
            _bid, _cid = [int(id) for id in bid_cid.split(':', 1)]
            if not _bid == bid:
                if Book.get(_bid) and Chapter.get(_cid, _bid):
                    rec_book_chapters.append(
                        (Book.get(_bid), Chapter.get(_cid, _bid))
                    )
    rec_book_chapters.insert(0, (book, chapter))
    rec_book_chapters = rec_book_chapters[:10]

    resp = make_response(render_template('content.html', **locals()))
    recent_reading_str = '|'.join(['%s:%s' % (book.id, chapter.id)
                         for book, chapter in rec_book_chapters])
    resp.set_cookie('recent_reading', recent_reading_str)
    return resp
开发者ID:amumu,项目名称:wyzq,代码行数:27,代码来源:app.py

示例2: m_book_modal

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get [as 别名]
def m_book_modal(bid):
    book = Book.get(bid)
    if request.method == 'POST':
        title = request.form.get('bookname')
        author = request.form.get('author')
        description = request.form.get('description')
        status = request.form.get('status')
        book.update(title, author, description, status)
        return redirect(request.referrer)
    return render_template('admin/book_modal.html', **locals())
开发者ID:amumu,项目名称:wyzq,代码行数:12,代码来源:app.py

示例3: recent_reading

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get [as 别名]
def recent_reading(request):
    recent_reading = request.cookies.get('recent_reading')
    recent_book_chapters = []
    if recent_reading:
        for bid_cid in recent_reading.split('|'):
            bid, cid = [int(id) for id in bid_cid.split(':', 1)]
            book = Book.get(bid)
            chapter = Chapter.get(cid, bid)
            if (book and chapter):
                recent_book_chapters.append((book, chapter))
        recent_book_chapters = recent_book_chapters[:10]
    return recent_book_chapters
开发者ID:amumu,项目名称:wyzq,代码行数:14,代码来源:app.py

示例4: appendBooks

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get [as 别名]
	def appendBooks(bookList, viewList):
		if bookList is None:
			bookList = BookList()
			
		if bookList.list is None: 
			bookList.list = ()
			
		for key in bookList.list[0:5]:
			bookKey = db.Key(key)
			if bookKey.app() == "trackmybooks":
				bookKey = db.Key.from_path(*bookKey.to_path())
			book = Book.get(bookKey)
			if book: viewList.append( mapping.toReaderBookTemplate(book, None) )
开发者ID:laimis,项目名称:trackmybooks,代码行数:15,代码来源:index.py

示例5: book

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get [as 别名]
def book(bid):
    is_faved = False
    if not current_user.is_anonymous():
        is_faved = Favourite.is_faved(current_user.id, bid)

    book = Book.get(bid)
    if not book:
        abort(404)
    chapters = Chapter.query.filter_by(book_id=bid)
    last_twelve_chapters = chapters.order_by(Chapter.id.desc()).limit(12)
    first_six_chapters = chapters.limit(6).all()
    first_six_chapters.reverse()
    return render_template('book.html', **locals())
开发者ID:amumu,项目名称:wyzq,代码行数:15,代码来源:app.py

示例6: get

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get [as 别名]
 def get(self):
     book = Book.get(self.request.get('key'))
     book.delete()
     self.redirect("/list")
开发者ID:jdevados,项目名称:booklistapp,代码行数:6,代码来源:books.py

示例7: chapters

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get [as 别名]
def chapters(bid):
    book = Book.get(bid)
    if not book:
        abort(404)
    chapters = Chapter.get_id_titles(book.id)
    return render_template('chapters.html', **locals())
开发者ID:amumu,项目名称:wyzq,代码行数:8,代码来源:app.py


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