本文整理汇总了Python中models.Game.all方法的典型用法代码示例。如果您正苦于以下问题:Python Game.all方法的具体用法?Python Game.all怎么用?Python Game.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Game
的用法示例。
在下文中一共展示了Game.all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def get(self, name):
if not users.get_current_user():
self.redirect(users.create_login_url(self.request.uri))
logging.info('Iniciando busca')
results = search_metacritic(name, 'game')
logging.info('Fetch concluido')
output = []
for result in results:
query = Img.all()
query.filter('url =', result[1])
img = query.fetch(1)[0]
query = Game.all()
query.filter('cover =', img)
if not query.count():
platform = str(result[1])[:str(result[1]).rfind('/')].replace('/game/','')
game = Game(name=str(result[0]),cover=img,platform=platform,score=str(result[2]))
game.put()
else:
game = query.fetch(1)[0]
output.append([img.key().id(), result[0], game.key().id()])
template_values = {'results': output}
path = os.path.join(os.path.dirname(__file__), 'search.html')
self.response.out.write(template.render(path, template_values))
示例2: games
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def games():
gs = Game.all()
games = {}
for g in gs:
game_id = str(g.key().id_or_name())
games[game_id] = parse_game(g)
return jsonify(**games) # does not render a page, just returns a Json
示例3: handle_event
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def handle_event(event):
home_team, away_team, date = find_event_info(event)
game = Game.all()\
.filter('home_team =', home_team)\
.filter('away_team =', away_team)\
.filter('start >=', date)\
.get()
if not game:
return logging.error(
'No game for %s @ %s @ %s' % (away_team, home_team, date))
markets = event.find('markets').findall('market')
points = None
for market in markets:
linetype = market.find('lineType')
if linetype is not None and linetype.text.strip() == 'PSH':
try:
points = float(market.find('points').text)
except ValueError:
logging.error(
'Unknown points: %r' % market.find('points').text)
points = None
break
game.spread = points
logging.info('%s: %s' % (game, points))
return game
示例4: get
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def get(self):
# Can't provide an ordering here in case inequality filters are used.
base_query = Game.all()
count = base_query.count()
results = base_query.fetch(count)
#db.delete(results)
# for game in results:
# resultsobj = resultsobj + simplejson.dumps({"latitude":game.location.lat,"longitude":game.location.lon,"name":game.name,"type":game.game_type})
# objs = simplejson.dumps(resultsobj)
public_attrs = Game.public_attributes()
results_obj = [
_merge_dicts({
'lat': result.location.lat,
'lng': result.location.lon,
},
dict([(attr, getattr(result, attr))
for attr in public_attrs]))
for result in results]
#for song in results:
#print song.type
# for result in query:
# resultsobj.push( "Title: " + result.address
self.response.out.write(simplejson.dumps({
'status': 'success',
'count': count,
'results': results_obj
}))
示例5: show_games
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def show_games():
# Getting all the games
gs = Game.all()
# Build dictionary
games = []
for g in gs:
games.append(to_dict(g))
print(games)
return render_template('show_games.html', games=games) # first games is key, games is value
示例6: create_new_game
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def create_new_game():
if Game.all().filter('title =', request.json['title']).count() == 0:
name_of_player_to_join = list(set(request.json['players'])) # Makes sure each player is registered only once
shuffle(name_of_player_to_join)
players_to_join = [Player.all().filter('username =', name).get() for name in name_of_player_to_join]
new_game = Game(title=request.json['title'], num_player=len(players_to_join))
new_game.put()
for i in range(-1, len(players_to_join)-1):
killer = players_to_join[i]
GamePlayer(game=new_game, player=killer).put()
target = players_to_join[i+1]
GameHistory(killer=killer, target=target, game=new_game, is_complete=False, confirm_msg=msg_generator()).put()
return jsonify({"success": True})
else:
return jsonify({"success": False})
示例7: index
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def index(request):
games = Game.all().order('-created_at')
return render_to_response('webigo/index.html', {'games':games})