本文整理汇总了Python中persistence.PersistenceManager.get_game方法的典型用法代码示例。如果您正苦于以下问题:Python PersistenceManager.get_game方法的具体用法?Python PersistenceManager.get_game怎么用?Python PersistenceManager.get_game使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类persistence.PersistenceManager
的用法示例。
在下文中一共展示了PersistenceManager.get_game方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: game
# 需要导入模块: from persistence import PersistenceManager [as 别名]
# 或者: from persistence.PersistenceManager import get_game [as 别名]
def game():
id = str(request.args.get('id'))
pm = PersistenceManager(myapp.db_connector)
game = pm.get_game(session,id)
if game == None:
return redirect(url_for('new'))
player1 = game.game_players[0]
player2 = game.game_players[1]
winning_player = "Unknown"
if game.game_winner is not None:
winning_player = game.game_winner.name
#summary_stats = GameSummaryStats(game)
game_tape = GameTape(game)
game_tape.score()
luck_result = pm.get_luck_score(session, game.id)
if luck_result is None:
luck_result = calculate_luck_result(game, game_tape=game_tape)
if luck_result is not None:
myapp.db_connector.get_session().add(luck_result)
myapp.db_connector.get_session().commit()
return render_template( 'game_summary.html',
game=game,
player1=player1,
player2=player2,
winner=winning_player,
game_tape=game_tape,
colorscale=colorscale() )