Пример #1
0
	def _make_unique_string(self):
		jenny = generate_random_of_length(10)
		testy = Abbrev.gql('WHERE gen_str = :1', jenny).get()
		if testy:
			self._make_unique_string()
		else:
			return jenny
Пример #2
0
	def get(self, generated_string):
		go_url = '/'
		if generated_string:
			abb = Abbrev.gql('WHERE gen_str = :1', generated_string.upper()).get()
			if abb:
				go_url = abb.user_link
		self.redirect(go_url)
Пример #3
0
	def post(self):
		url = self.request.get('url')
		if url:
			abb = Abbrev.gql('WHERE user_link = :1', url).get()
			if abb:
				self._render_success(abb.user_link, abb.gen_str)
			else:
				try:
					gengen = self._make_unique_string()
					Abbrev(user_link=url, gen_str=gengen).put()
					self._render_success(url, gengen)
				except:
					self._render_error('Datastore Error')
		else:
			self._render_error('No Query')