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


Python Blog.find方法代码示例

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


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

示例1: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def api_delete_blog(request, *, id):
    check_admin(request)
    # 根据model类的定义,只有查询才是类方法,其他删改都是实例方法
    # 所以要先创建一个实例
    blog = yield from Blog.find(id)
    yield from blog.remove()
    return dict(id=id) # 返回被删除博客的id
开发者ID:Patrickctyyx,项目名称:superawesome-python3-webapp,代码行数:9,代码来源:handlers.py

示例2: get_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def get_blog(id):
    blog = yield from Blog.find(id)
    comments = yield from Comment.findAll("blog_id=?", [id], orderBy="created_at desc")
    for c in comments:
        c.html_content = text2html(c.content)
    blog.html_content = markdown2.markdown(blog.content).replace("\n", "</br>")
    return {"__template__": "blog.html", "blog": blog, "comments": comments}
开发者ID:wp3xpp,项目名称:freemind-python,代码行数:9,代码来源:handlers.py

示例3: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def api_delete_blog(request, *, id):
    check_admin(request)  # 检查用户权限
    # 根据model类的定义,只有查询才是类方法,其他增删改都是实例方法
    # 因此需要先创建对象,再删除
    blog = yield from Blog.find(id)  # 取出博客
    yield from blog.remove()  # 删除博客
    return dict(id=id)  # 返回被删博客的id
开发者ID:lovelywxd,项目名称:blogs-web-python,代码行数:9,代码来源:handlers.py

示例4: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def api_delete_blog(request, *, id):
    check_admin(request)
    blog = yield from Blog.find(id)
    if blog is None:
        raise APIResourceNotFoundError('blog not found')
    yield from blog.delete()
    return dict(id=id)
开发者ID:pengxiaojun,项目名称:python_utils,代码行数:9,代码来源:handlers.py

示例5: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def api_delete_blog(request, *, id):
    check_admin(request)
    blog = yield from Blog.find(id)
    if blog is None:
        return APIResourceNotFoundError('Blog')
    yield from blog.remove()
    return dict(id=id)
开发者ID:githubao,项目名称:xiao-first-webapp,代码行数:9,代码来源:handlers.py

示例6: get_api_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def get_api_blog(id):
    blog=yield from Blog.find(id)    
    if blog:
        return blog
    else:
        raise APIValueError('id','wrong id')
        return None
开发者ID:jasonzhyan,项目名称:aiohttp-website,代码行数:9,代码来源:handlers.py

示例7: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def api_delete_blog(id, request):
    logger.info("删除博客的博客ID为:%s" % id)
    check_admin(request)
    b = yield from Blog.find(id)
    if b is None:
        raise APIResourceNotFoundError('Comment')
    yield from b.remove()
    return dict(id=id)
开发者ID:kHRYSTAL,项目名称:awesome_python3_webapp,代码行数:10,代码来源:handlers.py

示例8: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [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

示例9: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def api_delete_blog(id, request):
    logging.info('delete a blog %s', id)
    check_admin(request)
    blog = yield from Blog.find(id)
    if blog is None:
        raise APIResourceNotFoundError('blog not found')
    yield from blog.remove()
    raise dict(id=id)
开发者ID:crazyAxe,项目名称:aWebapp,代码行数:10,代码来源:handlers.py

示例10: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def api_delete_blog(id, request):
    check_admin(request)
    blog = yield from Blog.find(id)
    comments = yield from Comment.findAll(where="blog_id='%s'" % id)
    yield from blog.remove()
    for comment in comments:
        yield from comment.remove()
    return dict(id=id)
开发者ID:glistenlau,项目名称:blog-python3-webapp,代码行数:10,代码来源:handlers.py

示例11: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def api_delete_blog(request, *, id):
    # 校验当前用户权限:
    check_admin(request)
    # 数据库Blog表中查询指定文章信息:
    blog = yield from Blog.find(id)
    # 将Blog信息从数据库删除:
    yield from blog.remove()
    return dict(id=id)
开发者ID:DeadAddict,项目名称:Python_L_Webapp,代码行数:10,代码来源:handlers.py

示例12: api_delete_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def api_delete_blog(request, *, id):
    '''
    删除日志
    '''
    check_admin(request)
    blog = yield from Blog.find(id)
    yield from blog.remove()
    return dict(id=id)
开发者ID:handane123,项目名称:awesome-web-app,代码行数:10,代码来源:handlers.py

示例13: get_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def get_blog(id):
    # 通过id在数据库Blog表中查询对应内容:
    blog = yield from Blog.find(id)
    # 通过id在数据库Comment表中查询对应内容:
    comments = yield from Comment.findAll("blog_id=?", [id], orderBy="created_at desc")
    for c in comments:
        # 将content值从text格式转换成html格式:
        c.html_content = text2html(c.content)
    blog.html_content = markdown2.markdown(blog.content)
    return {"__template__": "blog.html", "blog": blog, "comments": comments}
开发者ID:DeadAddict,项目名称:Python_L_Webapp,代码行数:12,代码来源:handlers.py

示例14: create_comment

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def create_comment(*, blog_id, content):
    if not content or not content.strip():
        raise APIValueError('content', 'content cannot be empty')

    #get blog
    blog = yield from Blog.find(blog_id)
    comment = Comment(user_id=blog.user_id, user_name=blog.user_name, user_image=blog.user_image,
                      blog_id=blog_id, content=content)
    yield from comment.save()
    return comment
开发者ID:ianzhengnan,项目名称:blog-python3,代码行数:12,代码来源:handlers.py

示例15: get_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import find [as 别名]
def get_blog(id):
    blog = yield from Blog.find(id)
    comments = yield from Comment.findAll('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:hellozmz,项目名称:awesome_python3_webapp,代码行数:13,代码来源:handlers.py


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