Absolute beginner question:
I have a template file index.html that looks like this:
...
<FRAMESET ROWS="10%, *">
<FRAME SRC="/top_frame">
<FRAME SRC="{{ bottom_frame_url }}">
</FRAMESET>
...
And a request handler for /top_frame that looks like this:
class TopFrame(webapp.RequestHandler):
def get(self):
...
bottom_frame_url = self.request.get('bottom_frame_url')
...
As you can see I would like to have the value {{ bottom_frame_url }} that was used to generate my index.html, but how to I pass this value to my TopFrame request handler?
Thanks!
Edit: I am rendering index.html from another request handler:
class MainPage(webapp.RequestHandler):
def get(self):
...
bottom_frame_url = Site.qql("WHERE Category = :1 ORDER BY date DESC",category_name)
...
args = {
...
'bottom_frame_url': bottom_frame_url,
...
}
index_path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(index_path, args))
But when we encounter "/top_frame" in the index.html template my TopFrame request handler is called:
class TopFrame(webapp.RequestHandler):
def get(self):
...
bottom_frame_url = self.request.get('bottom_frame_url')
...
args = {
'bottom_frame_url': bottom_frame_url
}
self.response.out.write(template.render('topframe.html', args))
But self.request.get('bottom_frame_url') does not seem to be reading any value. I know the value has been set in my index.html template because when I render the page the bottom frame shows as the website I set, but the top frame displays a traceback ending in the following error:
NameError: global name 'bottom_frame_url' is not defined
It looks like I have to put some more code in my index.html template to explicitly pass the value of bottom_frame_url to my TopFrame request handler. Is this correct?
The other thing I can think of is that although I am passing bottom_frame_url as an argument to render index.html, when I try to render topframe.html this argument isn't available yet, because I haven't rendered the bottom frame yet. Could this be the case?