當前位置: 首頁>>代碼示例>>Python>>正文


Python Email.select方法代碼示例

本文整理匯總了Python中models.Email.select方法的典型用法代碼示例。如果您正苦於以下問題:Python Email.select方法的具體用法?Python Email.select怎麽用?Python Email.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Email的用法示例。


在下文中一共展示了Email.select方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: home

# 需要導入模塊: from models import Email [as 別名]
# 或者: from models.Email import select [as 別名]
def home(page_num):
    """ Handles the home page rendering."""
    thread_id_query = 'SELECT DISTINCT thread FROM email ORDER BY time DESC LIMIT %d, %d' % \
            (POSTS_PER_PAGE*(page_num-1), POSTS_PER_PAGE)
    thread_ids = [email.thread for email in RawQuery(Email, thread_id_query)]

    threads = []
    for thread_id in thread_ids:
        emails_query = 'SELECT * FROM email WHERE thread = %d ORDER BY time ASC' % thread_id
        threads.append([email for email in RawQuery(Email, emails_query)])

    num_pages = math.ceil(Email.select().group_by(Email.thread).count()/float(POSTS_PER_PAGE))

    view_data = {
        'threads'   : threads,
        'page_num'  : page_num,
        'num_pages' : num_pages,
        'site_name' : app.config['SITE_NAME'],
        'site_slogan'    : app.config['SITE_SLOGAN'],
    }
    return render_template('home.html', **view_data)
開發者ID:v,項目名稱:mailblog,代碼行數:23,代碼來源:app.py


注:本文中的models.Email.select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。