def _doGet(self):
		try:
			
			KM = KillMapper()
			
			if self.arg is not None:
				if self.arg.isdigit():
					# Get the user by ID
					kill = KM.find(self.arg)
				else:
					raise BadRequest("Kill must be requested by ID")

				if kill is not None:
					return self._response(Depth.build(kill, self.depth), CODE.OK)
				else:
					raise NotFound("This kill does not exist")
			
			else:
				offset = 0
				kills = KM.findAll(offset, offset+50)

				killslist = []
				for kill in kills:
					killslist.append(Depth.build(kill, self.depth))

				killdict = {"kills": killslist, "pagination_offset": offset, "max_perpage": 50}

				return self._response(killdict, CODE.OK)

		except mdb.DatabaseError, e:
				raise ServerError("Unable to search the kill database (%s: %s)" % e.args[0], e.args[1])
Exemple #2
0
	def _doGet(self):
		try:
			
			KM = KillMapper()
			
			if self.arg is not None:
				if self.arg.isdigit():
					# Get the user by ID
					kill = KM.find(self.arg)
				else:
					raise BadRequest("Kill must be requested by ID")

				if kill is not None:
					return self._response(kill.dict(), CODE.OK)
				else:
					raise NotFound("This kill does not exist")
			
			else:

				offset = 0
				kills = KM.findAll(offset, offset+50)

				killslist = []

				for kill in kills:
					killslist.append(kill.dict())

				killdict = {"kills":killslist, "pagination_offset":offset, "max_perpage": 50}

				return self._response(killdict, CODE.OK)

		except mdb.DatabaseError, e:
				raise ServerError("Unable to search the kill database (%s: %s)" % e.args[0], e.args[1])
Exemple #3
0
	def _doPost(self, dataObject):

		if "killer" and "victim" and "time" in dataObject:
			try:
				KM = KillMapper()
				GM = GameMapper()
				PM = PlayerMapper()

				if dataObject["killer"] is not None and dataObject["victim"] is not None:

					if "id" in dataObject["killer"] and "id" in dataObject["victim"]:
						# Get the user by ID
						killer = PM.find(dataObject["killer"]["id"])

						victim = PM.find(dataObject["victim"]["id"])

						try:
							proptime = parseDateTime(dataObject["time"])
						except:
							raise BadRequest("""Invalid Time object sent, acceptable formats: 	Acceptable formats are: "YYYY-MM-DD HH:MM:SS.ssssss+HH:MM",
							"YYYY-MM-DD HH:MM:SS.ssssss",
							"YYYY-MM-DD HH:MM:SS+HH:MM",
							"YYYY-MM-DD HH:MM:SS" """)

						if killer is None or victim is None:
							raise NotFound("Either the victim or the killer were invalid player objects")
					else:
						raise BadRequest("Arguments provided for this kill are invalid.")

				else:
					raise BadRequest("Arguments provided for this kill are invalid.")

				kill = Kill()

				kill.setKiller(killer)
				kill.setVictim(victim)
				kill.setVerified(False)

				kill.setTime(proptime)

				KM.insert(kill)

				return self._response(kill.dict(3), CODE.CREATED)
				
			except mdb.DatabaseError, e:
				raise ServerError("Unable to search the user database (%s)" % e.args[1])
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.qrzargamemapper import QRzarGameMapper
    from Model.Mapper.usermapper import UserMapper
    from Model.Mapper.killmapper import KillMapper
    from Model.Mapper.qrzarplayermapper import QRzarPlayerMapper
    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

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

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

    for kill_ in kills:
        print kill_

    PM = QRzarPlayerMapper()
    players = PM.findAll()

    for player_ in players:
        print player_

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

    usr1 = UM.find(1)
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)