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


Python Post.update方法代码示例

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


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

示例1: feed_update

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import update [as 别名]
def feed_update(id=None):

    # Manual update of one or all feeds now
    if request.json['action'] == 'refresh':
        
        # Call refresh routine
        # TODO: RSS worker functions in separate package
        # TODO: Need to capture return status
        if id is None:
            rss_spawn() # Update all feeds
        else:
            try:
                feed = Feed.get(Feed.id == id)
            except Feed.DoesNotExist:
                return jsonify(**FEED_NOT_FOUND)

            rss_worker(feed) # Update single feed
        
        # return JSON status OK
        return jsonify(**STATUS_OK)

    # Mark one or all feeds read
    elif request.json['action'] == 'markread':

        if id is None:
            # Mark all posts read
            query = Post.update(is_read=True)
        else:
            # Mark posts in current feed read
            query = Post.update(is_read=True).where(Feed.id == id)
            
        query.execute()
            
    # return JSON status OK
        return jsonify(**STATUS_OK)
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:37,代码来源:views.py

示例2: post_update_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import update [as 别名]
def post_update_post(id):
    postid = request.forms.get('postid')
    title = request.forms.get('title').decode('utf-8')
    slug = request.forms.get('slug').decode('utf-8')
    post = request.forms.get('post')
    tags = request.forms.get('tags').decode('utf-8')
    category = request.forms.get('category').decode('utf-8')
    post_type = request.forms.get('postype')
    if post_type == 'HTML':
        is_html = 1
        content = post.decode('utf-8')
        markdown = u'html'
    else:
        is_html = 0
        markdown = post.decode('utf-8')
        content = to_markdown(markdown)
    category = Category.get(name=category)
    Post.update(title=title, slug=slug, content=content, markdown=markdown,
                tags=tags, category=category,
                is_html=is_html).where(id=postid).execute()
    tag_list = set(tags.split(","))
    for tag in tag_list:
        try:
            Tag.get(name=tag.strip(), post_id=postid)
        except Post.DoesNotExist:
            Tag.create(name=tag.strip(), post_id=postid)
    redirect("/%s" % slug)
开发者ID:iTriumph,项目名称:MiniAkio,代码行数:29,代码来源:blog.py

示例3: save_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import update [as 别名]
def save_post():
    req_data = request.form
    post_id = req_data.get('postId')
    post_title = req_data.get('title')
    post_content = req_data.get('content')
    category_id = req_data.get('categoryId')
    post_status = req_data.get('postStatus')
    author_id = current_user.get_id()
    if post_id is not None:
        Post.update(author_id, post_title, post_content, post_status, category_id, post_id)
        return jsonify(status='200', postId=post_id)
    else:
        post_id = Post.save(author_id, post_title, post_content, post_status, category_id)
        return jsonify(status='200', postId=post_id)
开发者ID:FengNongtheWindCoder,项目名称:flaskblog,代码行数:16,代码来源:views.py

示例4: edit_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import update [as 别名]
def edit_post(post_id):
    """Replaces post behind id with submitted one"""
    post_d = mongo.db.posts.find_one(post_id)
    if post_d is None:
        abort(404) 
    form = PostEditForm.from_json(request.json, skip_unknown_keys=False)
    if form.validate():
        post = Post(bson=post_d)
        post.update(form.data)
        query = {'_id': post_id}
        mongo.db.posts.update(query, post.to_bson())
        # needed for chaining multiple edits together
        token = generate_csrf_token()
        return jsonify(_csrf=token, **post.to_dict())
    else:
        print form.errors #TODO
        abort(400)
开发者ID:amontalenti,项目名称:muckhacker,代码行数:19,代码来源:api.py

示例5: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import update [as 别名]
def post (identifier):
    pageinfo = {
        'title':        'post',
        'heading':      'view post',
    }
    pageinfo = generate_pageinfo(pageinfo)
    # This is probably dangerous; TODO: fix Post URL scheme.
    post = Post().get({'_id': ObjectId(identifier)})
    if post:
        post = dict(post)
        augment = {
            'html':         misaka.html(gfm.gfm(post['content'])),
            'author':         User().get({'_id': post['author']}),
        }
        post.update(augment)
        pageinfo.update({'post': post, 'heading': post['title'], 'title': post['title']})
    else:
        flash('Post not found: {0}')
    return render_template('post.html', pageinfo = pageinfo, models = models)
开发者ID:bsmithyman,项目名称:whiskey,代码行数:21,代码来源:views.py

示例6: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import update [as 别名]
    def post(self, postid):
        title = self.get_argument('title', None)
        slug = self.get_argument('slug', '')
        category_id = self.get_argument('category', 1)
        content = self.get_argument('content', '')
        tags = self.get_argument('tag', '')
        category = Category.get(id=int(category_id))

        Post.update(title=title, slug=slug,
                    category=category, content=content, tags=tags).where(Post.id == postid).execute()

        tag_list = set(tags.split(","))
        if tag_list:
            for tag in tag_list:
                try:
                    Tag.get(name=tag, post=postid)
                except Tag.DoesNotExist:
                    Tag.create(name=tag, post=postid)
        self.redirect('/admin/posts')
        return
开发者ID:dengmin,项目名称:logpress-tornado,代码行数:22,代码来源:admin.py

示例7: set_favourite

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import update [as 别名]
def set_favourite(id=None):
    # Toggle favourite status for post #id
    try:
        is_favourite = Post.get(Post.id == id).is_favourite
        query = Post.update(is_favourite=not is_favourite).where(Post.id == id)
        query.execute()
    except Post.DoesNotExist:
        return jsonify(**POST_NOT_FOUND)

    # return JSON status OK
    return jsonify(**STATUS_OK)
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:13,代码来源:views.py


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