本文整理汇总了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
示例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)
示例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("/")
示例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)
示例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}))
示例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))
示例7: sites
# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import all [as 别名]
def sites():
return json_list_response(Site.all().fetch(limit = 200))
示例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]
示例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))