本文整理汇总了Python中models.Location.all方法的典型用法代码示例。如果您正苦于以下问题:Python Location.all方法的具体用法?Python Location.all怎么用?Python Location.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Location
的用法示例。
在下文中一共展示了Location.all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import all [as 别名]
def post(self):
logging.error(dir(self.auth))
if not self.auth.user:
return Response('Error: authenticate first')
place_key_name = self.request.form.get('place_key_name')
l = Location.all().filter('osm =', place_key_name).fetch(1)
if not l:
l = Location(osm=place_key_name)
l.put()
else:
l = l[0]
c = Checkin(user=self.auth.user, location=l)
osmpoi = OSMPOI.get_by_key_name(place_key_name)
place_name = osmpoi.name
if place_name:
c.place_name = place_name
else:
c.place_key_name = osmpoi.key().name()
c.user_name = self.auth.user.username
c.put()
return Response('Success %s, %s' % (self.auth.user, place_key_name))
示例2: get
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import all [as 别名]
def get(self):
_lng = cgi.escape(self.request.get('lng'))
_lat = cgi.escape(self.request.get('lat'))
_distance = 5
center = geotypes.Point(float('14.550102'),
float('121.056186'))
#14.553803,121.050244
#results = Location.proximity_fetch(Location.all(), center, max_results=10, max_distance=100000000)
results = Location.all()
public_attrs = Location.public_attributes()
results_obj = [r.to_dict() for r in results]
self.response.out.write(simplejson.dumps({
'status': 'success',
'results': results_obj
}))
示例3: get
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import all [as 别名]
def get(self):
"""The API to get the list of locations from the database. The following
parameters can be specified:
building - (optional) the list of locations for the building
floor - (optional) the list of locations for the building and floor
Returns a list of locations in JSON format. An empty list will be returned
if there are no results for the specified parameters."""
locations = memcache.get(MC_LOCATIONS_KEY)
if not locations:
locations = list(Location.all())
memcache.set(MC_LOCATIONS_KEY, locations)
building = self.request.get('building')
floor = self.request.get('floor')
if building:
if floor:
f = lambda loc: loc.building == building and loc.floor == floor
else:
f = lambda loc: loc.building == building
locations = filter(f, locations)
self.render_json([str(location) for location in locations])
示例4: get_locations
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import all [as 别名]
def get_locations():
locations = memcache.get(MC_LOCATIONS_KEY)
if not locations:
locations = list(Location.all())
memcache.set(MC_LOCATIONS_KEY, locations)
return locations