Esempio n. 1
0
	def post(self):
		self.response.headers['Content-Type'] = "text/plain"
		tagname = self.request.get('tag')
		try: threadnumber = int(self.request.get('thread'))
		except:
			self.error(400)
			self.response.out.write("Thread number must be an integer")
			return
		tag = database.Tag.get_by_key_name(tagname)
		thread = database.Thread.get_by_key_name(str(threadnumber))
		if tag and thread:
			if database.findassociation(tag, thread):
				self.response.out.write("Association already in database")
			else:
				association = database.Association(tag=tag, thread=thread)
				association.put()
				tag.count_plus()
				tag.put()
				self.response.out.write(u"Association successful: %s labeled with %s" % (association.thread, association.tag))
		else:
			self.response.out.write("Association not successful:\n")
			if not tag:
				self.response.out.write("- Tag %s not found" % tagname)
			if not thread:
				self.response.out.write("- Thread #%s not found" % threadnumber)
Esempio n. 2
0
	def post(self):
		tagname = self.request.get('tag')
		threadnumber = int(self.request.get('thread'))
		tag = database.Tag.get_by_key_name(tagname)
		thread = database.Thread.get_by_key_name(str(threadnumber))
		self.response.headers['Content-Type'] = "text/plain"
		if tag and thread:
			association = database.findassociation(tag, thread)
			if association:
				association.cancelled = True
				association.put()
				tag.count_minus()
				tag.put()
				self.response.out.write(u"Dissociation successful: %s removed from %s" % (association.tag, association.thread))
			else:
				self.error(404)
				self.response.out.write("Association not found")
		else:
			self.error(404)
			self.response.out.write("Dissociation not successful:\n")
			if not tag:
				self.response.out.write("- Tag %s not found" % tagname)
			if not thread:
				self.response.out.write("- Thread #%s not found" % threadnumber)