#!/usr/bin/python2.5 # """One-line documentation for file module. A detailed description of file. """ __author__ = 'geo@barryhunter.co.uk (barry hunter)' import wsgiref.handlers import os from google.appengine.ext.webapp import template from google.appengine.ext import webapp from google.appengine.api import users class BaseFile(webapp.RequestHandler): def get(self): self.render(self.getTemplateFilename(), self.getTemplateValues()) def getTemplateValues(self): template_values = { 'http_host': self.request.environ['HTTP_HOST'] } return template_values def getTemplateFilename(self): return "base.kml" def render(self, filename, template_values): path = os.path.join(os.path.dirname(__file__), 'templates', filename) contentType = 'application/vnd.google-earth.kml+xml' self.response.headers['Content-Type'] = contentType self.response.out.write(template.render(path, template_values)) ## # Page class for the personal view class RefreshFile(BaseFile): ## # Returns a dictionary with values for the template def getTemplateValues(self): template_values = BaseFile.getTemplateValues(self) return template_values ## # Returns the filename of the template to use when # rendering def getTemplateFilename(self): return "vbr.kml" ## # Page class for the personal view class CenterFile(BaseFile): ## # Returns a dictionary with values for the template def getTemplateValues(self): template_values = BaseFile.getTemplateValues(self) return template_values ## # Returns the filename of the template to use when # rendering def getTemplateFilename(self): return "vbr-c.kml" application = webapp.WSGIApplication( [('/file/vbr.kml', RefreshFile), ('/file/vbr-c.kml', CenterFile)],debug=True) wsgiref.handlers.CGIHandler().run(application)