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


Python Tag.save方法代码示例

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


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

示例1: save_data

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import save [as 别名]
def save_data(s3client, field, bucket, key):
    for data in read_fields(s3client, field, bucket, key):
        tag = Tag()
        tag.name = data.strip()
        try:
            tag.save(force_insert=True)
        except IntegrityError:
            pass
开发者ID:npmajisha,项目名称:bag-the-job,代码行数:10,代码来源:tag-extractor.py

示例2: post

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import save [as 别名]
    def post(self):
        """Creates a new tag for the logged in user"""
        user = utils.get_current_user()
        title = self.request.get('title')
        new_title = self.request.get('newTitle') or None
        
        if not user:
            self.error(403)
            return
        
        if not title:
            self.error(400)

        # Create new tag
        if not new_title:
            m = Tag.all().ancestor(user).filter('title_lower =', title.lower()).get()
            
            if m:
                # Not unique
                self.error(409)
                return

            m = Tag(
                parent=user,
                title=title,
                title_lower=title.lower(),
            )
            m.put()

        # Rename Tag
        else:
            m = Tag.all().ancestor(user).filter('title_lower =', new_title.lower()).get()
            if m:
                # Not unique
                self.error(409)
                return

            m = Tag.all().ancestor(user).filter('title_lower =', title.lower()).get()
            if not m:
                # Original tag not found
                self.error(404)
                return

            m.title = new_title
            m.title_lower = new_title.lower()
            m.save()

        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
        self.response.headers['Access-Control-Allow-Origin'] = '*'
        self.response.out.write('ok')
开发者ID:studyindenmark,项目名称:newscontrol,代码行数:52,代码来源:tags.py

示例3: api_article_add

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

示例4: addTag

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import save [as 别名]
 def addTag(self, noteId, strTag):
     count = Tag.select().where(Tag.tag == strTag).count()
     if (count == 0):
         dbTag = Tag()
         dbTag.creationDate = dbTag.modificationDate = datetime.date.today()
         dbTag.tag = strTag
         dbTag.save()
     else:
         dbTag = Tag.get(Tag.tag == strTag)
         
     note = Note.get(Note.id == noteId)
     noteTag = NoteTag()
     noteTag.note = note
     noteTag.tag = dbTag
     noteTag.creationDate = noteTag.modificationDate = datetime.date.today()
     noteTag.save() 
     
     self.view.execute_script("notesMD.tags = " + RuntimeSettings.getTags())
开发者ID:nhrdl,项目名称:notesMD,代码行数:20,代码来源:notesmd.py

示例5: api_article_edit

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import save [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.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。