本文整理汇总了Python中models.Entry.get_entry方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.get_entry方法的具体用法?Python Entry.get_entry怎么用?Python Entry.get_entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Entry
的用法示例。
在下文中一共展示了Entry.get_entry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get_entry [as 别名]
def edit(slug):
if session.get('logged_in'):
entry = Entry.get_entry(slug, public=False)
else:
entry = Entry.get_entry(slug, public=True)
if entry is None:
return not_found(404)
if request.method == 'POST':
if request.form.get('delete'):
entry.delete()
flash('Post supprime', 'danger')
return redirect(url_for('news'))
if request.form.get('title') and request.form.get('content'):
entry.title = request.form['title']
entry.content = request.form['content']
entry.published = request.form.get('published') or False
entry.save()
flash('Entry saved successfully.', 'success')
if entry.published:
return redirect(url_for('detail', slug=entry.slug))
else:
return redirect(url_for('edit', slug=entry.slug))
else:
flash('Title and Content are required.', 'danger')
return render_template('edit.html', entry=entry)
示例2: detail
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get_entry [as 别名]
def detail(slug):
#TODO: implement drafts and publication handling
if session.get('logged_in'):
entry = Entry.get_entry(slug, public=False)
else:
entry = Entry.get_entry(slug, public=True)
if entry is None:
return not_found(404)
return render_template('detail.html', entry=entry)
示例3: post
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get_entry [as 别名]
def post(self, entry_id):
entry = Entry.update_entry(entry_id, self.request2params(self.request))
if entry is None:
entry = Entry.get_entry(entry_id)
return self.redirect('/admin/entry/%d?status=fail' % entry.key.id())
time.sleep(0.1)
return self.redirect('/admin/entry/%d?status=done' % entry.key.id())
示例4: get
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get_entry [as 别名]
def get(self, entry_id):
entry = Entry.get_entry(entry_id)
if entry is None:
return
template = jinja_environment.get_template('entry_edit.html')
return self.response.out.write(template.render({
'is_new': not not self.request.get('is_new', None),
'entry': entry,
'tagnames': json.dumps(Tag.get_tagnames(), ensure_ascii=False),
'status': self.request.get('status', None)
}))
示例5: get
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get_entry [as 别名]
def get(self, entry_id):
entry = Entry.get_entry(entry_id)
if entry is None:
self.response.set_status(404)
template = jinja_environment.get_template("404.html")
return self.response.out.write(template.render({}))
entries = Entry.get_entry_titles()
index = [e.key for e in entries].index(entry.key)
previous_entry = entries[index - 1] if index > 0 else None
next_entry = entries[index + 1] if index < len(entries) - 1 else None
Entry.increment_views(entry_id)
template = jinja_environment.get_template("blog_entry.html")
return self.response.out.write(
template.render(
{
"is_pc": is_pc(),
"entry": entry,
"previous": previous_entry,
"next": next_entry,
"request_url": self.request.url,
}
)
)