本文整理汇总了Python中post.Post.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Post.get_by_id方法的具体用法?Python Post.get_by_id怎么用?Python Post.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.get_by_id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import get_by_id [as 别名]
def get(self, post_id=None, action=None):
if action is None:
posts = Post.all()
self.response.out.write(helper.render('admin/posts', { 'posts': posts }))
elif action == "delete":
Post.get_by_id(int(post_id)).delete()
return self.redirect('/admin/posts')
elif action == "confirm":
post = Post.get_by_id(int(post_id))
post.confirmed_at = datetime.datetime.today()
post.put()
return self.redirect('/admin/posts')
示例2: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import get_by_id [as 别名]
def get(self, post_id):
try:
post = Post.get_by_id(int(post_id))
if not post:
raise Exception('Post with id %s not found' % post_id)
except Exception, e:
logging.error(e)
self.redirect('/')
return
示例3: YummyDone
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import get_by_id [as 别名]
def YummyDone(user_id, post_id):
user_delete_yummy = User.get_by_id(user_id)
post_delete_yummy = Post.get_by_id(post_id)
yummy = Yummy.all()
yummy.filter("user =", user_delete_yummy)
yummy.filter("post =", post_delete_yummy)
if (len(yummy.fetch(1000)) > 0):
return True
else:
return False
示例4: toogleYummy
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import get_by_id [as 别名]
def toogleYummy(user_id, post_id):
user_yummy = User.get_by_id(user_id)
post_yummy = Post.get_by_id(post_id)
if (not YummyDone(user_id, post_id)):
yummy = Yummy(user=user_yummy, post=post_yummy)
yummy.put()
return True
else:
yummy_delete = Yummy.all()
yummy_delete.filter("user =", user_yummy)
yummy_delete.filter("post =", post_yummy)
db.delete(yummy_delete.get())
return False
示例5: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import get_by_id [as 别名]
def get(self, id):
user = users.get_current_user()
if not user or not users.is_current_user_admin():
self.redirect(users.create_login_url(self.request.uri))
return
post = Post.get_by_id(int(id))
if post is None:
self.response.set_status(404)
return
template = jetpoweredblog.JINJA_ENVIRONMENT.get_template(
'templates/admin/posts-edit.html')
template_values = {
'post': post,
}
self.response.headers['Content-Type'] = 'text/html'
self.response.write(template.render(template_values))
示例6: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import get_by_id [as 别名]
def get(self, id):
post = Post.get_by_id(int(id))
if post is None:
self.response.set_status(404)
return
if not post.isPosted:
user = users.get_current_user()
if not user or not users.is_current_user_admin():
self.response.set_status(404)
return
template = JINJA_ENVIRONMENT.get_template(
'templates/post.html')
template_values = {
'post': post,
}
self.response.headers['Content-Type'] = 'text/html'
self.response.write(template.render(template_values))
示例7: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import get_by_id [as 别名]
def post(self, id):
user = users.get_current_user()
if not user or not users.is_current_user_admin():
self.redirect(users.create_login_url(self.request.uri))
return
post = Post.get_by_id(int(id))
if post is None:
self.response.set_status(404)
return
post.title = self.request.POST['title']
post.content = self.request.POST['content']
isPosted = 'isPosted' in self.request.POST
if(isPosted and not post.isPosted):
post.postedDate = datetime.datetime.now()
post.isPosted = isPosted
post.put()
self.response.set_status(204)
示例8: getPostYummys
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import get_by_id [as 别名]
def getPostYummys(post_id):
post_yummy = Post.get_by_id(post_id)
all_yummy = Yummy.all()
all_yummy.filter("post =", post_yummy)
return all_yummy.fetch(1000)