This is my implementation of a Masterpage like solution in Python. When using django.utils.simplejson it is possible to render Html Template against your Phython data.
First of all we can fetch the Url in a variable and map it to an Html Template file. A call template_values['content'] = template.render(content,template_values) will render the template and stores the result in a Data Array.
After that we can render the index.html (Our Python MasterPage File) and pass the requested template to the MainPage rendering process.
class MainPage(webapp.RequestHandler):
def post(self):
get()
def get(self):
data_query = MyData.all().order('-date')
data = data_query.fetch(10)
master = os.path.join(os.path.dirname(__file__), 'index.html')
u = (string.split(self.request.url,"/")[3])
content = os.path.join(os.path.dirname(__file__), '_'+u+'.html')
template_values = {}
#if u <> "":
template_values = {
"content": "",
"data1": "x",
"data2": "y"
}
template_values['content'] = template.render(content,template_values)
self.response.out.write(template.render(master, template_values))