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


Python Page.gql方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import gql [as 别名]
    def post(self, slug=None):
        if slug:
            page = Page.gql("WHERE slug = :1", slug).get()
        else:
            page = Page()
        page.title = self.request.get('title')
        page.slug = self.request.get('slug')
        page.content = self.request.get('content')
        page.order_in_menu = int(self.request.get('order_in_menu'))

        page.put()

        self.redirect(page.get_url())
开发者ID:ibz,项目名称:nuages,代码行数:15,代码来源:admin.py

示例2: render_template

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import gql [as 别名]
    def render_template(self, content_type, template_file, data=None):
        if data is None:
            data = {}
        data['admin'] = users.is_current_user_admin()
        data['settings'] = settings
        query = Page.gql("WHERE order_in_menu > 0 "
                         "ORDER BY order_in_menu")
        data['pages'] = [p for p in query]

        template_path = os.path.join(os.path.dirname(__file__), "templates")
        output = template.render(os.path.join(template_path, template_file), data)

        self.render(content_type, output)
开发者ID:ibz,项目名称:nuages,代码行数:15,代码来源:handler.py

示例3: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import gql [as 别名]
    def get(self, slug):

        # we want a canonical url with the trailing slash
        # so if it's missing we need to throw a 301, adding the slash in 
        # the process
        if slug[-1] != "/":
            self.redirect("%s/" % slug, True)
            return

        output = get_cache(slug)
        if output is None:

            try:
                item = Page.gql("WHERE internal_url=:1", slug)[0]
            except IndexError:
                self.error(404)
                output = self.render("404.html", {"title": "Page not found"})
                self.response.out.write(output)
                return
        
            # get a list of related items based on taggings
            # remember to filter out the article we're on
            related = []
            for tag in item.tags:
                 related += (Tag.all().filter('name =', tag).filter('title !=', item.title))
            
            # we also need to deduplicate the list as sometimes items
            # will share tags
            seen = [] 
            deduped = []
            for related_item in related:
                if not related_item.url in seen:
                    deduped.append(related_item)
                    seen.append(related_item.url)
        
            context = {
                "item": item,
                "related": deduped,
                "title": item.title,
            }
            output = self.render("item.html", context)
            memcache.add(slug, output, 3600)
        self.response.out.write(output)
开发者ID:garethr,项目名称:appengine-sitebuilder,代码行数:45,代码来源:main.py

示例4: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import gql [as 别名]
 def get(self, slug=None):
     if slug:
         page = Page.gql("WHERE slug = :1", slug).get()
     else:
         page = None
     self.render_html("page_edit", {'page': page})
开发者ID:ibz,项目名称:nuages,代码行数:8,代码来源:admin.py

示例5: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import gql [as 别名]
 def get(self, slug):
     page = Page.gql("WHERE slug = :1", slug).get()
     self.render_html("page_view", {'page': page})
开发者ID:ibz,项目名称:nuages,代码行数:5,代码来源:page.py


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