本文整理汇总了Python中models.Entry.select方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.select方法的具体用法?Python Entry.select怎么用?Python Entry.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Entry
的用法示例。
在下文中一共展示了Entry.select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: entry_view
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def entry_view(entry_id):
template_name = 'index.html'
if Entry.select().where(Entry.id == entry_id, Entry.is_active == True, Entry.parent == None).exists():
entries = Entry.select().where(Entry.id == entry_id, Entry.is_active == True)
responses = Entry.select().where(Entry.parent << entries)
else:
abort(404)
return views.render(template_name, entries=entries, responses=responses, is_entry=True)
示例2: show_entries
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def show_entries(page=1):
pagecount, perpage = calc_entries()
entries = Entry.select().order_by(-Entry.publishdate).paginate(int(page), perpage)
for entry in entries:
entry.year = entry.publishdate.year
if len(str(entry.publishdate.month))==1:
entry.month="0"+str(entry.publishdate.month)
else:
entry.month=entry.publishdate.month
if len(str(entry.publishdate.day))==1:
entry.day="0"+str(entry.publishdate.day)
else:
entry.day=entry.publishdate.day
entry.twitter = User.get(User.id==entry.user).twitter
page=int(page)
if page>1:
entries.newer=page-1
else:
entries.newer=None
if pagecount>page:
entries.older=page+1
else:
entries.older=None
return render_template('show_entries.html', entries=entries)
示例3: detail
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def detail(slug):
if session.get('logged_in'):
query = Entry.select()
else:
query = Entry.public()
entry = get_object_or_404(query, Entry.slug == slug)
return render_template('detail.html', entry=entry)
示例4: prune
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def prune():
from models import Entry
count = 0
for entry in Entry.select():
if not os.path.exists(entry.path):
entry.delete_instance()
count += 1
print(count, 'non-existent file entries cleared')
示例5: calc_entries
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def calc_entries():
paginate=10
entrycount = Entry.select().count()
if entrycount>paginate:
pagecount = ceil(entrycount/float(paginate))
else:
pagecount=1
return pagecount, paginate
示例6: remove_view
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def remove_view(entry_id):
user = Session.get_user()
if Entry.select().where(Entry.id == entry_id, Entry.user == user, Entry.is_active == True).exists():
entry = Entry.get(Entry.user == user, Entry.is_active == True)
entry.is_active = False
entry.save()
else:
abort(404)
return redirect(URLS['index'])
示例7: show_entry
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def show_entry(slug, year, month):
entry = Entry.select().where(Entry.publishdate.year==year).where(Entry.publishdate.month==month).where(Entry.slug==slug).get()
entry.year = entry.publishdate.year
if len(str(entry.publishdate.month))==1:
entry.month="0"+str(entry.publishdate.month)
else:
entry.month=entry.publishdate.month
if len(str(entry.publishdate.day))==1:
entry.day="0"+str(entry.publishdate.day)
else:
entry.day=entry.publishdate.day
entry.twitter = User.get(User.id==entry.user).twitter
if entry is None:
abort(404)
else:
return render_template('entry.html', entry=entry)
示例8: recent_feed
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def recent_feed():
feed=AtomFeed('Recent Posts',
feed_url=request.url, url=request.url_root)
posts = Entry.select().order_by(-Entry.publishdate).limit(15)
for post in posts:
post.year = post.publishdate.year
if len(str(post.publishdate.month))==1:
post.month="0"+str(post.publishdate.month)
else:
post.month=post.publishdate.month
feed.add(post.title, unicode(post.text), content_type='html',
author = post.user.user_first+' '+post.user.user_last,
url = 'http://carboy.tommeagher.com/entries/{0}/{1}/{2}.html'.format(post.year, post.month, post.slug),
published = datetime.combine(post.publishdate, datetime.min.time()), updated=datetime.combine(post.publishdate, datetime.min.time()))
return feed.get_response()
示例9: new_view
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def new_view(parent_id=None):
user = Session.get_user()
if parent_id and Entry.select().where(Entry.id == parent_id, Entry.is_active == True).exists():
parent = Entry.get(Entry.id == parent_id, Entry.is_active == True)
else:
parent = None
title = views.form_get('title', 'no title')
body = views.form_get('body', '')
Entry.create(
user=user,
parent=parent,
title=title,
body=body,
)
return redirect(URLS['index'])
示例10: check_correctness
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def check_correctness():
from models import Entry
size_miss, time_miss, count = 0, 0, 0
for hash_entry in get_duplicates():
entries = Entry.select().where(Entry.hash_str == hash_entry.hash_str)
size, last_modified, path = None, None, None
for entry in entries:
if size:
if entry.size != size:
print('Size mismatch:', hash_entry.hash_str, entry.size, size, entry.path)
size_miss += 1
elif entry.last_modified != last_modified:
if abs(entry.last_modified - last_modified) < 5:
continue
print('Time mismatch:', hash_entry.hash_str, entry.last_modified, last_modified, path, entry.path)
time_miss += 1
else:
size, last_modified, path = entry.size, entry.last_modified, entry.path
count += 1
print('Mismatches: size {}, time {} of total {} duplicates'.format(size_miss, time_miss, count))
示例11: index_view
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def index_view():
template_name = 'index.html'
entries = Entry.select().where(Entry.parent == None, Entry.is_active == True)
return views.render(template_name, entries=entries, is_index=True)
示例12: list_entries_subquery
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def list_entries_subquery(user):
return list(Entry.select().where(Entry.blog << Blog.select().where(Blog.user == user)))
示例13: list_entries_by_user
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def list_entries_by_user(user):
return list(Entry.select().join(Blog).where(Blog.user == user))
示例14: list_entries_subquery
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def list_entries_subquery(user):
return list(Entry.select().where(blog__in=Blog.select().where(user=user)))
示例15: ip_exist
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import select [as 别名]
def ip_exist(form, field):
"""Check if the IP entered already exists"""
if Entry.select().where(Entry.ip == field.data).exists():
raise ValidationError("That IP is already registered.")