當前位置: 首頁>>代碼示例>>Python>>正文


Python Site.all方法代碼示例

本文整理匯總了Python中models.Site.all方法的典型用法代碼示例。如果您正苦於以下問題:Python Site.all方法的具體用法?Python Site.all怎麽用?Python Site.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Site的用法示例。


在下文中一共展示了Site.all方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: RetriveSongsBySite

# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import all [as 別名]
def RetriveSongsBySite(site_name):    
    #if you dont pass anything in it gets all the sites
    if site_name == '':
        site = Site.all().fetch(150)
    else:
        site = Site.all().filter('name =', site_name).fetch(1)
        
    return site
開發者ID:BenjaminDavison,項目名稱:machinehype-gae,代碼行數:10,代碼來源:controllers.py

示例2: get

# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import all [as 別名]
    def get(self):

        sites = Site.all()

        context = {
            'sites': sites,
        }

        sites_for_output = {}
    
        # loop over the sites
        for site in sites:
            # and store each one in the output variable
            site_for_output = {
                "url": site.url,
                "issues": site.issue_set.count(),
            }
            sites_for_output[site.name] = site_for_output
    
        # create the JSON object we're going to return
        json = simplejson.dumps(sites_for_output, sort_keys=False)

        # serve the response with the correct content type
        #self.response.headers['Content-Type'] = 'application/json'
        # write the json to the response
        self.response.out.write(json)
開發者ID:4sp1r3,項目名稱:fixmysite,代碼行數:28,代碼來源:main.py

示例3: get

# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import all [as 別名]
    def get(self):
        "Ping each site in turn and record the response"
        # get all the sites we're going to ping
        sites = Site.all()

        # loop over all of the current sites
        for site in sites:
            # ping each site
            ping_site(site)

        self.redirect("/")
開發者ID:rootart,項目名稱:appengine-uptime,代碼行數:13,代碼來源:main.py

示例4: observation_update_all

# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import all [as 別名]
def observation_update_all():

    sites = Site.all().fetch(limit = 200)
    for site in sites:
        taskqueue.add(url = "/admin/sites/%s/observation/update" % site.key().id_or_name(), queue_name="update")
        taskqueue.add(url = "/admin/sites/%s/observation/update2" % site.key().id_or_name(), queue_name="update")

    if request.args.get("redirect"):
        flash("Started update observation tasks for all sites")
        return redirect(url_for('sites'))

    return Response(status = 204)
開發者ID:tempredirect,項目名稱:MetOfficeWatch,代碼行數:14,代碼來源:views.py

示例5: post

# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import all [as 別名]
 def post(self):
     site_name = self.request.get('site_name')
     
     #this is dodgy, I would rather do something like Site.get(name=site_name) but I can't get that
     #to work...
     p = Site.all().filter('name =', site_name).fetch(1)
     
     if users.get_current_user():
         Song(site = p[0],
              title = self.request.get('title'),
              mp3_url = self.request.get('mp3_url'),
              likes = 0).put()
              
         self.redirect('/?' + urllib.urlencode({'site_name': p[0].name}))
開發者ID:BenjaminDavison,項目名稱:machinehype-gae,代碼行數:16,代碼來源:controllers.py

示例6: post

# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import all [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

示例7: sites

# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import all [as 別名]
def sites():
    return json_list_response(Site.all().fetch(limit = 200))
開發者ID:tempredirect,項目名稱:MetOfficeWatch,代碼行數:4,代碼來源:sites.py

示例8: findSite

# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import all [as 別名]
'''
Created on Feb 23, 2011

@author: jackdreilly
'''
from models import Site

qlsites = Site.all().fetch(100)

    
def findSite(url,type):
	return [site for site in qlsites if site.name in url and site.type == type][0]
開發者ID:jackdreilly,項目名稱:quiklyrics,代碼行數:14,代碼來源:qlsite.py

示例9: sites

# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import all [as 別名]
def sites():
    return render_template("sites.html", sites = Site.all().fetch(limit = 200))
開發者ID:tempredirect,項目名稱:MetOfficeWatch,代碼行數:4,代碼來源:views.py


注:本文中的models.Site.all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。