# search for a player and if found, create a new one (w/ hashkey)
def get_or_create_player(session=None, hashkey=None):
- # the player object we'll return
- player = None
-
# if we have a bot
if re.search('^bot#\d+$', hashkey):
player = session.query(Player).filter_by(player_id=1).one()
player = session.query(Player).filter_by(
player_id=hashkey.player_id).one()
log.debug("Found existing player {0} with hashkey {1}.".format(
- player.player_id, hashkey.hashkey)
+ player.player_id, hashkey.hashkey))
except:
player = Player()
session.add(player)
hashkey = Hashkey(player_id=player.player_id, hashkey=hashkey)
session.add(hashkey)
log.debug("Created player {0} with hashkey {1}.".format(
- player.player_id, hashkey.hashkey)
+ player.player_id, hashkey.hashkey))
return player