コード例 #1
0
ファイル: games.py プロジェクト: waynet/TopHat-Platform
    def _doGet(self):
        try:

            GM = GameMapper()

            if self.arg is not None:
                if self.arg.isdigit():
                    # Get the user by ID
                    game = GM.find(self.arg)
                elif self.arg == "types":
                    return self._response({}, CODE.UNIMPLEMENTED)
                else:
                    raise BadRequest("Games must be requested by ID")

                if game is not None:
                    return self._response(game.dict(3), CODE.OK)
                else:
                    raise NotFound(
                        "There is no game identified by the number %s" %
                        self.arg)

            else:

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

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

                gameslist = []

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

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

                return self._response(gamedict, CODE.OK)

        except mdb.DatabaseError, e:
            raise ServerError(
                "Unable to search the game database (%s: %s)" % e.args[0],
                e.args[1])
コード例 #2
0
ファイル: mappertest2.py プロジェクト: waynet/TopHat-Platform
def main():
	from Common.config import TopHatConfig

	#setup the config
	kwargs = {"path":"/home/specialk/Dev/tophat/config.py"}
	TopHatConfig(**kwargs)

	# do the other stuff
	from Model.Mapper.gamemapper import GameMapper
	from Model.Mapper.usermapper import UserMapper
	from Model.Mapper.killmapper import KillMapper
	from Model.Mapper.playermapper import PlayerMapper
	from Model.Mapper.apitokenmapper import ApitokenMapper
	from Model.Mapper.objectwatcher import ObjectWatcher

	# Get All the current Users from the database
	UM = UserMapper()
	users = UM.findAll()
	for usr in users:
		print usr

	KM = KillMapper()
	kills = KM.findAll()

	for kill_ in kills:
		print kill_

	PM = PlayerMapper()
	players = PM.findAll()

	for player_ in players:
		print player_

	GM = GameMapper()
	games = GM.findAll()
	for game_ in games:
		print game_

	ATM = ApitokenMapper()
	tokens = ATM.findAll()
	for token in tokens:
		print token

	usr1 = UM.find(1)
コード例 #3
0
ファイル: games.py プロジェクト: Specialkbyte/TopHat-Platform
	def _doGet(self):
		try:
			
			GM = GameMapper()
			
			if self.arg is not None:
				if self.arg.isdigit():
					# Get the user by ID
					game = GM.find(self.arg)
				elif self.arg == "types":
					return self._response({}, CODE.UNIMPLEMENTED)
				else:
					raise BadRequest("Games must be requested by ID")

				if game is not None:
					return self._response(game.dict(3), CODE.OK)
				else:
					raise NotFound("There is no game identified by the number %s" % self.arg)
			
			else:

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

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

				gameslist = []

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

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

				return self._response(gamedict, CODE.OK)

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