本文整理汇总了Python中post.Post.update方法的典型用法代码示例。如果您正苦于以下问题:Python Post.update方法的具体用法?Python Post.update怎么用?Python Post.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import update [as 别名]
def post(self,post_id):
if not self.user:
self.redirect('/blog/%s' % post_id)
subject = self.request.get('subject')
content = self.request.get('content')
user_id = self.user.key().id()
last_modified = datetime.datetime.now()
post = Post.by_id(post_id)
if post and post.created_by == user_id:
Post.update(post_id,subject,content,last_modified)
self.redirect('/blog/%s' % post_id)
示例2: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import update [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: update
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import update [as 别名]
def update():
request_data = get_json(request)
code, response = Post.update(request_data['post'], request_data['message'])
return json.dumps(
{'code': code,
'response': response}
)
示例4: expand
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import update [as 别名]
def expand(self,board,post_id, message=None):
if not self.in_course_list(board):
return "whatever."
# pass
post = Post(board, post_id=post_id)
if cherrypy.request.method == 'POST':
if not message:
print('Message was empty')
pass #Add to errors or something...
else:
post.add_reply(message)
post.update()
#display the post and responses for post_id
post = Post(board, post_id=post_id)
#Render the page
name_space = {'post':post,'course':board}
return str(Template(self.expand_template, name_space))