当前位置: 首页>>代码示例>>Python>>正文


Python Post.get_by_id方法代码示例

本文整理汇总了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')
开发者ID:grunskis,项目名称:neperczagtu.lv,代码行数:14,代码来源:admin.py

示例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
开发者ID:grunskis,项目名称:neperczagtu.lv,代码行数:11,代码来源:info.py

示例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
开发者ID:andrefreitas,项目名称:feup-ldso-foodrific,代码行数:12,代码来源:yummy.py

示例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
开发者ID:andrefreitas,项目名称:feup-ldso-foodrific,代码行数:15,代码来源:yummy.py

示例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))
开发者ID:eholec,项目名称:jetpoweredblog,代码行数:22,代码来源:posts.py

示例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))
开发者ID:eholec,项目名称:jetpoweredblog,代码行数:23,代码来源:jetpoweredblog.py

示例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)
开发者ID:eholec,项目名称:jetpoweredblog,代码行数:26,代码来源:posts.py

示例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)
开发者ID:andrefreitas,项目名称:feup-ldso-foodrific,代码行数:7,代码来源:yummy.py


注:本文中的post.Post.get_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。