webgo/deletegame.py

22 lines
488 B
Python
Raw Normal View History

import helper,database
def main(gamename):
"""
manage the removal of game from game slots of players and
delete game from database.
TODO: add option do undo deletion when a failure happens
"""
#get player names from game table in database
mygame=database.GobanTable.get(gamename)
players = mygame.players()
#free game slots of players
for player in players:
myuser = database.Users.byUsername(player)
myuser.remove_game(gamename)
#delete table
mygame.destroySelf()