def get(self): Utils.reset(self) # reset/clean standard variables # validate and assign parameters passwd = Utils.required(self, 'passwd') uuid = Utils.required(self, 'uuid') guid = self.request.get('guid') # check password if self.error == '' and passwd != config.testing['passwd']: self.error = 'passwd is incorrect.' start_time = time.time() # start count # if error, skip this if self.error == '': # query player state for given uuid players = Player.all().filter('uuid =', uuid).ancestor( db.Key.from_path('Player', config.db['playerdb_name'])).fetch(1) didDelete = False # we have not delete anything yet for player in players: # we might have duplicate data, just delete them all # query scores for this player and delete them all scores = Score.all().filter('uuid =', player.uuid).ancestor( db.Key.from_path('Score', config.db['scoredb_name'])) for score in scores: score.delete() # query items for this player and delete them all items = Item.all().filter('uuid =', player.uuid).ancestor( db.Key.from_path('Item', config.db['itemdb_name'])) for item in items: item.delete() # query records for this player and delete them all records = Record.all().filter('uuid =', player.uuid).ancestor( db.Key.from_path('Record', config.db['recorddb_name'])) for record in records: record.delete() # query buildings for this player and delete them all buildings = Building.all().filter( 'uuid =', player.uuid).ancestor( db.Key.from_path('Building', config.db['buildingdb_name'])) for building in buildings: building.delete() cars = Car.all().filter('uuid =', player.uuid).ancestor( db.Key.from_path('Car', config.db['cardb_name'])) for car in cars: car.delete() # delete all this user's challenge Challenge.DeleteByUserId(self, player.uuid) # and finally, delete this player player.delete() didDelete = True # compose result if didDelete == True: self.respn = '"' + uuid + ' was deleted successfully."' else: self.error = uuid + ' does not exist in Database.' # calculate time taken and return the result time_taken = time.time() - start_time self.response.headers['Content-Type'] = 'text/html' self.response.write(Utils.RESTreturn(self, time_taken))