本文整理匯總了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)