本文整理汇总了Python中models.Location.query方法的典型用法代码示例。如果您正苦于以下问题:Python Location.query方法的具体用法?Python Location.query怎么用?Python Location.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Location
的用法示例。
在下文中一共展示了Location.query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import query [as 别名]
def post(self, request_id):
location = self.request.get('location')
# Get request
request = ndb.Key(urlsafe=request_id).get()
location = location.split('^')
# Check if location has been previously used
existing_location = Location.query(Location.name == location[0], Location.address == location[1]).get()
if existing_location is None:
# Add new location
categories = location[3].split(',')
coordinates = location[4].split(' ')
new_location = Location()
new_location.name = location[0]
new_location.address = location[1]
new_location.image_url = location[2]
for c in categories:
new_location.categories.append(c)
new_location.longitude = float(coordinates[0])
new_location.latitude = float(coordinates[1])
new_location.put()
else:
new_location = existing_location
if request != None:
# Check if already appended
add = True
if len(request.bidders) > 0:
for bid in request.bidders:
bid = bid.get()
if bid.name == self.user_model.username:
print "Already bid"
add = False
if add is True:
print "Haven't bid"
bidder = Bidder()
bidder.sender = self.user_model.key
bidder.location = new_location.key
bidder.name = self.user_model.username
bidder.bid_time = datetime.datetime.now() - datetime.timedelta(hours=8)
bidder.price = request.price
bidder.put()
request.bidders.append(bidder.key)
request.status = "pending"
request.put()
else:
print "Already connected"
self.redirect('/feed')
示例2: list_location
# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import query [as 别名]
def list_location():
l = Location()
l.lat = 1.0
l.lng = 1.0
l.put()
vals = ''
q = Location.query()
n = q.count()
for e in q:
vals += str(e) + '<br><br>'
# e.key.delete()
return '<h3>%d</h3><br>%s' % (n, vals)