本文整理汇总了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)