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


Python Comment.find_all方法代码示例

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


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

示例1: weibo_tag

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find_all [as 别名]
 def weibo_tag(weibo):
     comment_list = Comment.find_all(weibo_id=weibo.id)
     comments = '<br>'.join([c.content for c in comment_list])
     # format 函数的字典用法
     # 注意 u.id 是 current_user
     # user.username 是博主
     w = {
         'id': weibo.id,
         'user_id': u.id,
         'content': weibo.content,
         'username': user.username,
         'time': weibo.created_time,
         'comments': comments,
     }
     # 手动处理 weibos 这个 list
     # 把每个 weibo 以 <p> 的形式展现在页面
     return """
         <p>{content} from {username}@{time}
             <a href="/weibo/delete?id={id}">删除</a>
             <a href="/weibo/edit?id={id}">修改</a></p>
             <button class="weibo-show-comment" data-id="{id}">评论</button>
             <div>
                 {comments}
             </div>
             <div id="id-div-comment-{id}" class="weibo-comment-form weibo-hide">
                 <form action="/weibo/comment/add" method="post">
                     <input name="user_id" value="{user_id}" type="hidden">
                     <input name="weibo_id" value="{id}" type="hidden">
                     <textarea name="content"></textarea>
                     <button type="submit">添加评论</button>
                 </form>
             </div>
         </p>
         """.format(**w)
开发者ID:gayu-mike,项目名称:learnweb,代码行数:36,代码来源:routes_weibo.py

示例2: api_comments

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find_all [as 别名]
def api_comments(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Comment.find_num('count(id)')
    p = Page(num, page_index)
    if num == 0:
        return dict(page=p, comments=())
    comments = yield from Comment.find_all(orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, comments=comments)
开发者ID:chris5641,项目名称:simple-blog,代码行数:10,代码来源:handlers.py

示例3: api_delete_blog

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find_all [as 别名]
def api_delete_blog(request, *, id):
    check_admin(request)
    blog = yield from Blog.find(id)
    yield from blog.remove()
    comments = yield from Comment.find_all('blog_id=?', [id])
    for c in comments:
        yield from c.remove()
    return dict(id=id)
开发者ID:utopiaprince,项目名称:python-blog,代码行数:10,代码来源:handlers.py

示例4: get_blog

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find_all [as 别名]
def get_blog(id):
    blog = yield from Blog.find(id)
    comments = yield from Comment.find_all('blog_id=?', [id], orderBy='created_at desc')
    for c in comments:
        c.html_content = text2html(c.content)
    blog.html_content = markdown2.markdown(blog.content)
    return {
        '__template__': 'blog.html',
        'blog': blog,
        'comments': comments
    }
开发者ID:chris5641,项目名称:simple-blog,代码行数:13,代码来源:handlers.py

示例5: blog_id

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import find_all [as 别名]
def blog_id(id):
    if request.method == 'POST':
        comment_content = request.form['comment_content']
        comment_name = request.form['comment_name']
        comment = Comment(id=next_id(), blog_id=id, user_id='guest', user_name=comment_name,
                          user_image='',
                          content=comment_content, created_at=time.time())
        comment.save()
        image = common.create_avatar_by_name(comment_name)
        user = User(id=next_id(), email='', passwd='', admin=0, name=comment_name,
                    image=image,
                    created_at=time.time())
        mylog.info(image)
        # TODO 先使用name来进行判定是否唯一,后期希望能够使用email来判断是否唯一
        _user = User.find_all('name= ?', [comment_name])
        if len(_user) == 0:
            user.save()
        flash('comment and new user had been saved successfully!')

    blog = Blog.find(id)
    md_text = highlight.parse2markdown(blog.content)
    blog.html_content = md_text
    comments = Comment.find_all('blog_id= ?', [id])
    return render_template('blogdetail.html', blog=blog, comments=comments)
开发者ID:fantianwen,项目名称:web_blog,代码行数:26,代码来源:app.py


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