本文整理汇总了Python中post.Post.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Post.delete方法的具体用法?Python Post.delete怎么用?Python Post.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import delete [as 别名]
def get(self):
post_id = self.request.get('post_id')
if not self.user or not post_id:
self.redirect('/blog/%s' % post_id)
post = Post.by_id(post_id)
if post and post.created_by == self.user.key().id():
Post.delete(post_id)
self.redirect('/blog')
示例2: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import delete [as 别名]
def post(id=None):
if request.method == 'POST':
setting = request.form.get('setting')
post_id = request.form.get('value_0')
value = request.form.get('value_1')
if not setting or not post_id:
abort(400)
try:
post_id = int(post_id)
except:
abort(400)
post = Post(post_id=post_id)
if not post.id:
abort(400)
if setting == 'delete':
post.delete()
flash(messages.post_deleted)
if request.form.get('next'):
return redirect(request.form['next'])
return redirect(url_for('admin_post'))
elif setting == 'public':
if not value:
abort(400)
if value == 'True':
post.set_public()
flash(messages.post_marked_public)
else:
post.update('is_public', False)
flash(messages.post_marked_private)
return redirect(url_for('admin_post_id', id=post_id))
else:
if id:
post = Post(post_id=id)
post = post.get_post()
if not post:
flash(messages.post_not_found)
else:
post = None
return render_template('admin/post.html', post=post)
示例3: del_post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import delete [as 别名]
def del_post(args):
Post.delete(args.postid)