def _doPost(self, dataObject): if ( "name" in dataObject and "game" in dataObject and "respawn_code" in dataObject and "reference_code" in dataObject ): TM = TeamMapper() team = Team() try: game = GameMapper().find(dataObject["game"]["id"]) if game is None: raise NotFound("The specified game id was not found on the server.") team.setGame(game) except mdb.DatabaseError, e: raise ServerError("Unable to search the teams or players database (%s)" % e.args[1]) team.setName(dataObject["name"]) team.setRespawnCode(dataObject["respawn_code"]) team.setReferenceCode(dataObject["reference_code"]) try: TM.insert(team) except mdb.DatabaseError, e: raise ServerError("Unable to create the team in the database (%s)" % e.args[1])
def _doCreateObject(self, data): """Builds the game object given the draw data returned from the database query""" from Model.team import Team from Model.qrzargame import QRzarGame from Model.deferredobject import DeferredObject team = Team(data["id"]) # game reference game = DeferredObject(QRzarGame(data["game_id"])) team.setGame(game) # rest of the vars team.setName(data["name"]) team.setRespawnCode(data["respawn_code"]) team.setReferenceCode(data["reference_code"]) return team