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


Python Site.gql方法代码示例

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


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

示例1: index

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import gql [as 别名]
def index():
    user = users.get_current_user()
    if user:
        if not UserSettings.has_seen_example() and GqlQuery('SELECT __key__ FROM Site WHERE owner=:1 AND example=true', user).count(1) == 0:
            _create_example_site(user)
            UserSettings.mark_example_as_seen()
        sites = Site.gql('WHERE users=:1 ORDER BY name', user)
        site_form = PageForm()
        page_form = PageForm()
        return render_template('index.html', sites=sites, new_site_form=site_form, page_form=page_form)
    else:
        return home()
开发者ID:1ncnspcuous,项目名称:WebPutty,代码行数:14,代码来源:views.py

示例2: _whois

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import gql [as 别名]
def _whois():
    key = request.args.get('key', None)
    email = request.args.get('email', None)
    page = None
    user_sites = None
    if key:
        page = Page.get_or_404(key)
    if email:
        user_sites = Site.gql('WHERE users = :1', User(email))
    if key or email:
        return render_template('_whois_result.html', key=key, page=page, email=email, user_sites=user_sites)
    return render_template('_whois.html')
开发者ID:1ncnspcuous,项目名称:WebPutty,代码行数:14,代码来源:views.py

示例3: delete

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import gql [as 别名]
 def delete(self, name):
     "Delete the named resource"
     # check the resource exists
     try:
         # if it does then delete it
         site = Site.gql("WHERE name=:1", name)[0]
         site.delete()
     except IndexError:
         # site didn't exist
         return self.error(404)
     except:
         # something else went wrong
         return self.error(500)
开发者ID:rootart,项目名称:appengine-uptime,代码行数:15,代码来源:main.py

示例4: get

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

        site = Site.gql("WHERE slug=:1", slug)[0]

        context = {
            'site': site,
        }

        # prepare the context for the template
        # calculate the template path
        path = os.path.join(os.path.dirname(__file__), 'templates',
            'site.html')
        # render the template with the provided context
        self.response.out.write(template.render(path, context))
开发者ID:4sp1r3,项目名称:fixmysite,代码行数:16,代码来源:main.py

示例5: get

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

        # get the site we're going to ping
        try:
            # retrieve the site based on its name value
            site = Site.gql("WHERE name=:1", name)[0]
        except IndexError:
            # if we don't find a site then throw a Not Found error
            return self.error(404)

        # ping the site and store the response
        ping_site(site)

        # back to the home page
        self.redirect("/")
开发者ID:rootart,项目名称:appengine-uptime,代码行数:17,代码来源:main.py

示例6: put

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import gql [as 别名]
    def put(self, name):
        "Updates or Creates are managed through put on the name"

        # get the json from the body of the request
        json = self.request.body
        # convert the JSON to a Python object
        representation = simplejson.loads(json)
        # set the properties
        url = representation["url"]
        email = representation["email"]

        # we need to check whether this is an update
        try:
            site = Site.gql("WHERE name=:1", name)[0]
            site.url = url
            site.email = email
        except IndexError:
            # or a create
            site = Site(name=name, url=db.Link(url), email=db.Email(email))
        # either way we need to save the new object
        site.put()
开发者ID:rootart,项目名称:appengine-uptime,代码行数:23,代码来源:main.py

示例7: post

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import gql [as 别名]
    def post(self):
        
        """
        site = Site(
            name = 'name',
            url = 'http://url.com',            
            slug = 'slug',
        )
        site.put()
        
        issue = Issue(
            title = 'title',
            description = 'description',
            site = site,
        )
        issue.put()
        """

        # get url and then decide if we have a site already or
        # need to create one
        
        
        
        name = self.request.get("name")
        url = self.request.get("url")
        
        try:
            site = Site.gql("WHERE url=:1", url)[0]
        except IndexError:
            
            """
            import sys
            import pdb
            for attr in ('stdin', 'stdout', 'stderr'):
                setattr(sys, attr, getattr(sys, '__%s__' % attr))
            pdb.set_trace()
            """
            
            site = Site(
                name = name,
                url = url,            
                slug = slugify(name),
            )
            site.put()

        title = self.request.get("title")
        description = self.request.get("description")

        issue = Issue(
            title = title,
            description = description,
            site = site,
        )
        issue.put()


        context = {
            'issue': issue,
            'sites': Site.all(),
        }

        # prepare the context for the template
        # calculate the template path
        path = os.path.join(os.path.dirname(__file__), 'templates',
            'index.html')
        # render the template with the provided context
        self.response.out.write(template.render(path, context))
开发者ID:4sp1r3,项目名称:fixmysite,代码行数:69,代码来源:main.py


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