示例#1
0
	def _doGet(self):
		try:
			
			GTM = GameTypeMapper()
			
			if self.arg is not None:
				if self.arg.isdigit():
					# Get the user by ID
					gametype = GTM.find(self.arg)

					if gametype is not None:
						return self._response(gametype.dict(3), CODE.OK)
					else:
						raise NotFound("The specified game type does not exist.")
				else:
					raise BadRequest("Argument provided for this URL is invalid.")
			else:

				offset = 0
				games = GTM.findAll(offset, offset+50)

				if games is None:
					raise NotFound("There are no game types on this system.")

				gameslist = []

				for game in games:
					gameslist.append(game.dict())

				gamedict = {"gametypes":gameslist, "pagination_offset":offset, "max_perpage": 50}

				return self._response(gamedict, CODE.OK)

		except mdb.DatabaseError, e:
			raise ServerError("Unable to search the gametype database (%s: %s)" % e.args[0], e.args[1])