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


Python Post.find_by_id方法代码示例

本文整理汇总了Python中models.Post.find_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Post.find_by_id方法的具体用法?Python Post.find_by_id怎么用?Python Post.find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Post的用法示例。


在下文中一共展示了Post.find_by_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: status

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
def status(name, id):
	post = Post.find_by_id(id)
	if post:
		if post.user.username == name:
			return render_template('single.html', header='page', username=post.user.username, tweet=post, page='single.html', logged=user_is_logged())

	abort(404)
开发者ID:kevinmangan,项目名称:Tweeter,代码行数:9,代码来源:routes.py

示例2: delete

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
def delete(user, id):
	post = Post.find_by_id(id)
	if post:
		Post.delete(user,id)
		return redirect('/home')
	else:
		abort(404)
开发者ID:kevinmangan,项目名称:Tweeter,代码行数:9,代码来源:routes.py

示例3: comment_page

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
def comment_page(post_id):
    user_id = session.get('user_id')
    if user_id:
        post = Post.find_by_id(post_id)
        return render_template('comment_post.html', post = post,user_id=user_id)
    else:
        return redirect(url_for('index'))
开发者ID:zhengqm,项目名称:neo4j-weibo,代码行数:9,代码来源:controllers.py

示例4: get

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
    def get(self, path):
        if not self.user:
            self.redirect('/login')

        post_id = self.request.get('id')
        if post_id and post_id.isdigit():
            post = Post.find_by_id(post_id=int(post_id), path=path)
            if not post:
                self.abort(404)
        else:
            post = Post.find_by_path(path=path).get()

        self.render("edit_post.html", path=path, post=post)
开发者ID:michael-mao,项目名称:thewikihub,代码行数:15,代码来源:handlers.py

示例5: show_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
def show_post(post_id):
    # Check login status
    post = Post.find_by_id(post_id)
	# Search all the comments related.
    comments = Post.retrieve_comments(post_id)
    likes = Post.retrieve_likes(post_id)

    if post:
        self_id = session.get('user_id')
        if self_id:
            me_like = any(r.u['id'] == self_id for r in likes)
        else:
            me_like = False

        poster = Post.find_poster(post_id)
        return render_template('post_page.html', post=post, poster=poster.one, comments=comments, likes=likes, me_like=me_like)
    else:
        return redirect(url_for('index'))
开发者ID:zhengqm,项目名称:neo4j-weibo,代码行数:20,代码来源:controllers.py


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