本文整理汇总了Python中models.Player.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Player.gql方法的具体用法?Python Player.gql怎么用?Python Player.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Player
的用法示例。
在下文中一共展示了Player.gql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: action
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import gql [as 别名]
def action(request):
player = Player.gql("WHERE imei = :1", request.GET['imei']).get()
if not player:
return HttpResponseRedirect("/api/newgame/?imei=%s"%request.GET['imei'])
player.game_requested = datetime.now()
game = player.game
if not game:
return HttpResponseRedirect("/api/newgame/?imei=%s"%request.GET['imei'])
game.setup(player)
if request.GET.has_key('queue'):
game.apply_turn_queue(request.GET['queue'])
game.check_over()
if game.is_over: player.game = None
game.save()
player.put()
return HttpResponse(sj.dumps(game.to_response()))
示例2: new_game
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import gql [as 别名]
def new_game(request):
player = Player.gql("WHERE imei = :1", request.GET['imei']).get()
if not player:
player = Player(imei = request.GET['imei'])
player.game_requested = datetime.now()
player.put()
# Because there cant be two inequals in one query
opponents = Player.gql("WHERE game_requested > :1 ", datetime.now() - timedelta(0, 45)).fetch(2)
opponents = filter(lambda x: x.imei != request.GET['imei'], opponents)
if opponents:
opponent = opponents[0]
player.game_requested, opponent.game_requested = None, None
game = CheckersGame.create(player1 = opponent, player2 = player)
player.game, opponent.game = game, game
game.setup()
game.put()
player.put()
opponent.put()
return HttpResponseRedirect("/api/action/?imei=%s"%request.GET['imei'])
return HttpResponse(sj.dumps({'status' : 'waiting'}))
示例3: login
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import gql [as 别名]
def login():
error = None
if request.method == 'POST':
check_user = Player.gql("WHERE username = :username", username=request.form['username'])
if check_user.count() == 0:
error = 'Username does not exist'
elif not verify_password(request.form['password'], check_user.get().password_hash):
error = "Invalid password"
else:
session['logged_in'] = True
flash('You were logged in')
return redirect(url_for('show_games'))
return render_template('login.html', error=error)