Exemplo n.º 1
0
 def deletePlayer(cls, playerId):
     player = Player.get_by_id(playerId, parent=None)
     parentGame = Game.get_by_id(player.parentId)
     parentGame.playerIds.remove(playerId)
     parentGame.put()
     memcache.delete(str(playerId), namespace='players')
     player.key.delete()
Exemplo n.º 2
0
 def deletePlayer(cls, playerId):
     player = Player.get_by_id(playerId, parent=None)
     parentGame = Game.get_by_id(player.parentId)
     parentGame.playerIds.remove(playerId)
     parentGame.put()
     memcache.delete(str(playerId), namespace='players')
     player.key.delete()
Exemplo n.º 3
0
    def getPlayersForGame(cls, gameId):
        game = Game.get_by_id(int(gameId));

        # Initialize string representations of player and entity IDs
        game.makeStringValuedIds()

        # Get all cached buddies
        buddyDictionary = memcache.get_multi( game.playerIdStrings, key_prefix='player' )

        # Go through all buddy-keys of the parent game
        for playerId in game.playerIdStrings:
            # if one is missing, reload from the database and add to the buddy dictionary
            if playerId not in buddyDictionary:
                buddyDictionary[playerId] = Player.get_by_id( int(playerId), parent=None )

        # Now we're sure everybody is there. No Child Left Behind.
        # Everybody is in the dictionary. A good time to write it to the cache again
        memcache.set_multi(buddyDictionary)

        # The caller is only interested in the values of the dictionary.
        return buddyDictionary.values()
Exemplo n.º 4
0
    def getPlayersForGame(cls, gameId):
        game = Game.get_by_id(int(gameId))

        # Initialize string representations of player and entity IDs
        game.makeStringValuedIds()

        # Get all cached buddies
        buddyDictionary = memcache.get_multi(game.playerIdStrings,
                                             key_prefix='player')

        # Go through all buddy-keys of the parent game
        for playerId in game.playerIdStrings:
            # if one is missing, reload from the database and add to the buddy dictionary
            if playerId not in buddyDictionary:
                buddyDictionary[playerId] = Player.get_by_id(int(playerId),
                                                             parent=None)

        # Now we're sure everybody is there. No Child Left Behind.
        # Everybody is in the dictionary. A good time to write it to the cache again
        memcache.set_multi(buddyDictionary)

        # The caller is only interested in the values of the dictionary.
        return buddyDictionary.values()
Exemplo n.º 5
0
 def getGameForPlayer(cls, playerId):
     player = Player.get_by_id(playerId, parent=None)
     return Game.get_by_id(player.parentId, parent=None)
Exemplo n.º 6
0
 def getById(cls, id):
     return Game.get_by_id(id, parent=None)
Exemplo n.º 7
0
 def getGameForPlayer(cls, playerId):
     player = Player.get_by_id(playerId, parent=None)
     return Game.get_by_id(player.parentId, parent=None)
Exemplo n.º 8
0
 def getById(cls, id):
     return Game.get_by_id(id, parent=None)