def get(self, selected_aircraft=None):
		
		template_values = {
			'conf': conf
		}

		if selected_aircraft:
			query = db.GqlQuery("SELECT * FROM  Aero where aero = :1", selected_aircraft) 
			aero = query.get()
			#print "aero=", aero
			if aero:
				airdb = Aircraft()
				template_values['title'] = aero.description
				template_values['aero'] = aero
				template_values['content_template'] = 'aero_include.html'
				template_values['path'] =  '/aircraft/'
				client = app.Issues.GoogleIssuesClient()
				issues = client.aero(aero.aero)
				#print issues
				template_values['issues']  = issues
				query = db.GqlQuery("SELECT * FROM  AeroFile where directory = :1", aero.directory) 
				aero_files = query.fetch(20)
				template_values['aero_files'] = aero_files

				template_values['videos'] = get_videos(selected_aircraft)
				#print template_values
			else:
				self.redirect("/aircraft/?search=%s" % selected_aircraft)

		else:
			""" Show all aircraft or searched"""
			search_text = ""
			airdb = Aircraft()
			if self.request.get("search"):
				search_text = self.request.get("search").lower()
				aircraft = []
				if search_text:
					query = Aero.all()
					dbair = query.fetch(1000)
			
					for aero in dbair:
						#print aero.aero, search_text,  aero.aero.find(search_text)
						if aero.description.lower().find(search_text)  > -1:
							#print "match", search_str
							aircraft.append(aero)
			else:
				aircraft = airdb.get_all()
			
			
			template_values['title'] = 'Aircraft'
			template_values['aircraft'] = aircraft 
			template_values['search_text'] = search_text
			template_values['content_template'] = 'aircraft_include.html'
			template_values['path'] =  '/aircraft/'
		
		path = os.path.join(os.path.dirname(__file__), 'templates/aircraft.html')
		self.response.out.write(template.render(path, template_values))
	def get_all(self):

		data = memcache.get("aircraft_all")
		if data is not None:
			return data

		query = Aero.all()
		query.order("description")
		aircraft = query.fetch(20)

		aircraft_list = {}
		for aero in aircraft:
			aircraft_list[aero.aero] = aero.description
		if not memcache.set("aircraft_list", data, 5):
			print "error=aircraft_list"
		
		if not memcache.set("aircraft_all", data, 5):
			print "error=aircraft_all"

		return aircraft
	def get(self, selected_aircraft=None):
		
		template_values = {
			'conf': conf
		}
		search_text = self.request.get("query")
		aircraft_list = []
		if search_text:
			query = Aero.all()
			aircraft = query.fetch(1000)
			
			for aero in aircraft:
				#print aero.aero, search_text,  aero.aero.find(search_text)
				if aero.aero.find(search_text)  > -1:
					#print "match", search_str
					aircraft_list.append({'aero': aero.aero, 'description': aero.description})

		payload = {'success': True, 'aircraft': aircraft_list, 'count': len(aircraft_list)}
		self.response.headers['Content-Type'] = 'text/plain'
		self.response.out.write(json.dumps(payload))
	def get(self, section):
		fgApp = app.fetch.FGApp()
		template_values = {
			'path': '/idea/%s/' % section,
			'conf': conf,
			'app': fgApp
		}

		#if section == 'gallery':
		#	template_values['gallery'] = app.fetch.gallery_thumbs()

		#if section == "multiplayer":
		#		template_values['servers'] = app.fetch.mpservers()

		if section == "download":
				sql = "SELECT * FROM DownloadServer ORDER BY location"
				query = db.GqlQuery(sql)
				template_values['download_servers'] = query.fetch(100)
				template_values['title'] = 'Download Central'

		if section == 'about':
			template_values['title'] = 'About FlightGear'

		if section == 'aircraft': # and subpage == "aircraft":
			
			## 
			aero_request = self.request.get("aero")
			if aero_request:
				query = db.GqlQuery("SELECT * FROM  Aero where aero = :1", aero_request) 
				aero = query.get()
				#print "aero=", aero_request, aero.description
				if aero:
					##airdb = Aircraft()
					template_values['title'] = aero.description
					template_values['aero'] = aero
					##template_values['content_template'] = 'aero_include.html'
					##template_values['path'] =  '/aircraft/'
					##client = app.Issues.GoogleIssuesClient()
					##issues = client.aero(aero.aero)
					#print issues
					##template_values['issues']  = issues
					##q#uery = db.GqlQuery("SELECT * FROM  AeroFile where directory = :1", aero.directory) 
					##aero_files = query.fetch(20)
					##template_values['aero_files'] = aero_files

					##template_values['videos'] = get_videos(selected_aircraft)
					#print template_values
				else:
					self.redirect("/aircraft/?search=%s" % aero_request)

			else:
				search_text = ""
				airdb = Aircraft()
				if self.request.get("search"):
					search_text = self.request.get("search").lower()
					aircraft = []
					if search_text:
						query = Aero.all()
						dbair = query.fetch(1000)
				
						for aero in dbair:
							#print aero.aero, search_text,  aero.aero.find(search_text)
							if aero.description.lower().find(search_text)  > -1:
								#print "match", search_str
								aircraft.append(aero)
				else:
					aircraft = airdb.get_all()
				
				
				template_values['title'] = 'Aircraft'
				template_values['aircraft'] = aircraft 
				template_values['search_text'] = search_text
				#template_values['liveries'] = app.fetch.liveries()




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