Exemplo n.º 1
0
	def get(self, linkid):
		# check for login cookie.
		logging.info("Checking for cookie")
		idHash = self.request.cookies.get(user.USER_COOKIE_KEY)
		if idHash == None:
			logging.info("No cookie found")
			self.response.headers.add_header('Set-Cookie', user.LogoutUser())
		else:
			logging.info("Got Cookie: %s" %idHash)
			cookie_username = library.check_hash_str(idHash)
			logging.info("resulting username: %s" %cookie_username)
			username_verify = user.queryUsername(cookie_username)
			if username_verify != None:
				logging.info("Loading user and logging in")
				user.loadUserAccount(cookie_username)
				user.LoginUser()
			else:
				logging.info("Unable to find cookie match")
				self.response.headers.add_header('Set-Cookie', user.LogoutUser())

		"""Get a page for just the link identified."""
		links_list = link.getLinkByID(long(linkid))
		if links_list == None:
			self.response.set_status(404, 'Not Found')
			return      
		
		
		links = [links_list]

		template_values = create_template_dict_with_single_link(user, links_list, 'Link', nexturi=None, prevuri=None, page=0)
		template_file = os.path.join(os.path.dirname(__file__), 'templates/singlelink.html')    
		self.response.out.write(template.render(template_file, template_values))
Exemplo n.º 2
0
	def get(self):
		logging.info("Checking for cookie")
		idHash = self.request.cookies.get(user.USER_COOKIE_KEY)
		if idHash == None:
			logging.info("No cookie found")
			self.response.headers.add_header('Set-Cookie', user.LogoutUser())
		else:
			logging.info("Got Cookie: %s" %idHash)
			cookie_username = library.check_hash_str(idHash)
			logging.info("resulting username: %s" %cookie_username)
			username_verify = user.queryUsername(cookie_username)
			if username_verify != None:
				logging.info("Loading user and logging in")
				user.loadUserAccount(cookie_username)
				user.LoginUser()
			else:
				logging.info("Unable to find cookie match")
				self.response.headers.add_header('Set-Cookie', user.LogoutUser())


		links_list = link.queryLinks('Popular')
		template_values = create_template_dict(user, links_list, 'Popular', 0, 0, 0)

		template_file = os.path.join(os.path.dirname(__file__), 'templates/main.html')    
		self.response.out.write(template.render(template_file, template_values))