Beispiel #1
0
	def dispatch(self, request, *args, **kwargs):
		with Session() as s:
			try:
				fileName = kwargs['file']
				prefix, basename = splitFileName(kwargs['file'])
				title = a2b_hex(basename)
				atime = int(kwargs['time'])
				id_hex = kwargs['id']
				id_bin = a2b_hex(id_hex)
				addr = kwargs['node'].replace('+', '/')
			except (BadFileNameException, binascii.Error, ValueError):
				return HttpResponseBadRequest()

			if addr.startswith(':') or addr.startswith('/'):
				addr = request.META['REMOTE_ADDR'] + addr
			response = HttpResponse()
			if prefix=='thread':
				if Recent.get(s, atime, id_bin, fileName).first():
					return response
				thread_id = Thread.get(s, title=title).value(Thread.id)
				if thread_id:
					msgqueue.getAndUpdateRecord(addr, thread_id, id_hex, atime)
				try:
					Recent.add(s, timestamp=atime, binId=id_bin, fileName=fileName)
					s.commit()
				except IntegrityError:
					s.rollback()
			return response
Beispiel #2
0
	def dispatch(self, request, *args, **kwargs):
		with Session() as s:
			try:
				prefix, basename = splitFileName(kwargs['file'])
			except BadFileNameException:
				return HttpResponseBadRequest()

			response = HttpResponse()
			if prefix=='thread':
				try:
					title = a2b_hex(basename)
				except (TypeError, binascii.Error):
					return HttpResponseBadRequest()
				if Thread.get(s, title=title).value(Thread.id):
					response.write('YES')
					return response
			response.write('NO')
			return response
Beispiel #3
0
	def dispatch(self, request, *args, **kwargs):
		with Session() as s:
			try:
				prefix, basename = splitFileName(kwargs['file'])
				stime, etime = getTimeRange(
						kwargs.get('time'),
						kwargs.get('stime'),
						kwargs.get('etime'),
						)
			except (BadFileNameException, BadTimeRange):
				return HttpResponseBadRequest()

			response = HttpResponse()
			if prefix=='thread':
				try:
					title = a2b_hex(basename)
				except binascii.Error:
					return HttpResponseBadRequest()
				thread_id = Thread.get(s, title=title).value(Thread.id)
				allRecords = Record.gets(s, thread_id, stime, etime)
				for line in record2str(allRecords, 1):
					response.write(line)
			return response