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


Python Tag.findAll方法代码示例

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


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

示例1: api_article_add

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import findAll [as 别名]
def api_article_add(*, request, title, category, tag, content, summary):
    r = web.Response()
    blog = Blogs(title = title, user_id = getWebCookie(request, 'id'), summary = summary, content = content)
    id = yield from blog.save()
    category = urldecode(category)
    category = category[0].split(',')
    tags = tag.split('/')
    if id > 0:
        #文章分类插入
        for i in category:
            blog_category = BlogCategory(blog_id = id, category_id = i)
            blog_category_id = yield from blog_category.save()
        #标签分类插入
        for t in tags:
            t = t.strip()
            tag_title = yield from Tag.findAll('title=?', [t])
            #如果标签存在,则插入博客标签表,若不存在,则两张表都要插入
            if len(tag_title) > 0:
                tag_id = tag_title[0].get('id')
            else:
                tag = Tag(title = t)
                tag_id = yield from tag.save()
            blog_tag = BlogTag(blog_id = id, tag_id = tag_id)
            blog_tag_id = yield from blog_tag.save()
    if id > 0 and blog_category_id > 0 and blog_tag_id > 0:
        result = APIResult(1, '', '发布成功')
    else:
        result = APIResult(0, '', '发布失败')
    return jsonResult(r, result)
开发者ID:hearain528,项目名称:blog,代码行数:31,代码来源:handlers.py

示例2: api_article_edit

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import findAll [as 别名]
def api_article_edit(*, request, id, title, category, tag, content, summary):
    r = web.Response()
    blog = yield from Blogs.findOne(id)
    blog = Blogs(id = id, title = title, summary = summary, content = content, update_time = currentTime(), create_time = blog.get('create_time'), user_id = blog.get('user_id'), view_count = blog.get('view_count'))
    result = yield from blog.update()
    category = urldecode(category)
    category = category[0].split(',')
    tags = tag.split('/')
    blog_category_id = 0
    blog_tag_id = 0
    if result > 0:
        #文章分类插入
        blog_category_sql = 'delete from blog_category where blog_id = ?'
        yield from execute(blog_category_sql, [id])
        blog_tag_sql = 'delete from blog_tag where blog_id = ?'
        yield from execute(blog_tag_sql, [id])

        for i in category:
            blog_category = BlogCategory(blog_id = id, category_id = i)
            blog_category_id = yield from blog_category.save()
        #标签分类插入
        for t in tags:
            t = t.strip()
            tag_title = yield from Tag.findAll('title=?', [t])
            #如果标签存在,则插入博客标签表,若不存在,则两张表都要插入
            if len(tag_title) > 0:
                tag_id = tag_title[0].get('id')
            else:
                tag = Tag(title = t)
                tag_id = yield from tag.save()
            blog_tag = BlogTag(blog_id = id, tag_id = tag_id)
            blog_tag_id = yield from blog_tag.save()
    if int(id) > 0 and int(blog_category_id) > 0 and int(blog_tag_id) > 0:
        result = APIResult(1, '', '修改成功')
    else:
        result = APIResult(0, '', '修改失败')
    return jsonResult(r, result)
开发者ID:hearain528,项目名称:blog,代码行数:39,代码来源:handlers.py


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