Example #1
0
	def get_search_result(self, search_key,cursor_start,tags_or_people):
		key_length = len(search_key)
		if key_length <= 3:
			""" **************************************************
				**************************************************
				Retrieve the username from encoded username for len < 3.
			    *************************************************
			    *************************************************"""
			if tags_or_people == 'tags':
				tagsdb = TagsDB.all().filter('tagname =',search_key).fetch(100)
			elif tags_or_people == 'people':
				tagsdb = UserDB.all().filter('username =',search_key).fetch(100)
			l = []
			for i in tagsdb:
				l.append((i.tagname,1))
		elif key_length > 3 and key_length <= 5:
			mismatch = 1
			l = self.return_tags_username(mismatch, search_key, tags_or_people)
		elif key_length > 5 and key_length <= 8:
			mismatch = 2
			l = self.return_tags_username(mismatch, search_key, tags_or_people)
		else:
			mismatch = 3
			l = self.return_tags_username(mismatch, search_key, tags_or_people)
		return set(l)
Example #2
0
	def get_tags(self):
		tags = []
		tagsdb = TagsDB.all().fetch(1000)
		for tag in tagsdb:
			if tag.tagname and tag.tagname not in tags:
				tags.append(tag.tagname)
		return sorted(tags)
Example #3
0
	def return_tags_username(self, mismatch, search_key, tags_or_people):
		l = []
		if tags_or_people == 'tags':
			tagsdb = TagsDB.all().fetch(1000)
			for i in tagsdb:
				if abs(len(i.tagname) - len(search_key)) > mismatch+1:
					continue
				else:
					var = self.within_mismatch_limit(mismatch, i.tagname, search_key)
					if var or var == 0 :
						if (i.tagname,var) not in l:
							l.append((i.tagname,var))
			return l

		elif tags_or_people == 'people':
			userdb = UserDB.all().fetch(1000)
			for i in userdb:
				username = self.return_username_if_valid_cookie(i.username)
				if abs(len(username) - len(search_key)) > mismatch+1:
					# print 'if'
					continue
				else:
					# print 'else'
					var = self.within_mismatch_limit(mismatch, username, search_key)
					if var or var == 0 :
						if (username,var) not in l:
							l.append((username,var))
			return l
Example #4
0
	def loadAllTagsDb(self, filter = "", update = False):

		key = 'alltagskey'
		tagsdb = memcache.get(key)
		if not tagsdb or update:
			tagsdb = TagsDB.all().fetch(100)
			memcache.set(key,tagsdb)
			tagsdb = list(tagsdb)
		return tagsdb
Example #5
0
 def get_tags(self, username=""):
     if not username:
         tagsdb = TagsDB.all().fetch(500)
         tags = []
         for i in tagsdb:
             tags.append(i.tagname)
         return set(tags)
     else:
         """call searchpages function"""
Example #6
0
	def load_upload(self,title, content, username, username_ck, tag1 = "", tag2 = "", tag3 = ""):
		users = UserDB.all().filter('username ='******'-rating', update = True)
			self.loadAllTagsDb(update = True)

			self.redirect('/done/%d'%post_username.key().id())
			break
		# if not users:
		# 	content = "no usres returned from the query " +  username_ck
		"""instead of passing to the new_page redirect to the done page"""