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


Python Entry.is_external_page方法代码示例

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


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

示例1: post

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import is_external_page [as 别名]
    def post(self):
        # add new post or edit existed post
        t_values = {}
        current_post_id = self.request.POST["current_post_id"]
        post_title = self.request.POST["blog_title"]
        post_slug = get_safe_slug(self.request.POST["blog_slug"])
        post_content = self.request.POST["blog_content"]
        # find category
        blog_category_id = self.request.POST["blog_category_id"]
        post_category = Category.get_by_id(long(blog_category_id))
        if post_category:
            logging.info("find category %s for id %s" % (post_category.name, blog_category_id))
        else:
            logging.error("category id %s can't be located" % (blog_category_id))

        if current_post_id:
            logging.info("PostManager: post : edit post current_post_id = %s" % (current_post_id))
            # update existed post
            post = Entry.get_by_id(long(current_post_id))
            if post:
                t_values['alert_message'] = "Post %s has been updated!" % (post.title)
                post.title = post_title
                post.slug = post_slug
                post.content = post_content
                post.entrytype = "post"
                # update category count if this post is public
                if post.is_external_page and post.category != post_category:
                    if post.category and (post.category.entrycount > 0):
                        post.category.entrycount -= 1
                        post.category.put()
                    post_category.entrycount += 1
                    post.category.put()
                post.category = post_category
                post.put()
        else:
            logging.info("PostManager: post : new post title %s" % (self.request.POST['blog_title']))
            # create new post
            post = Entry()
            post.title = post_title
            post.slug = post_slug
            post.content = post_content
            post.entrytype = 'post'
            post.category = post_category
            # save as public or private?
            operation = self.request.POST["submit_action"]
            if operation == "save_publish":
                post.is_external_page = True
                # update category count
                post.category.entrycount += 1
                post.category.put()
            else:  # "save" operation
                post.is_external_page = False
            # save the post
            post.put()
            t_values['alert_message'] = "Post %s has been created!" % (post.title)

        # show all posts
        posts = Entry.all().filter("entrytype =", 'post')
        t_values['posts'] = posts
        return self.response.out.write(render_template("posts.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:62,代码来源:admin.py


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