I got the following very basic template:
<html>
<head>
</head>
<body>
<div>
<!-- Using "for" to iterate through potential pages would prevent getting empty strings even if only one page is returned because the "page" is not equal the query, it is a subcomponent of the query -->
<div>{{ page.name }}</div>
<div>{{ page.leftText }}</div>
<div>{{ page.imageURL }}</div>
<div>{{ page.rightText }}</div>
</div>
</body>
</html>
And the very basic Model:
class Page(db.Model):
name = db.StringProperty(required=True)
leftText = db.TextProperty()
rightText = db.TextProperty()
imageURL = db.LinkProperty()
And the very basic Handlers:
class BaseRequestHandler(webapp.RequestHandler):
#######
class PageContentLoadRequestHandler(BaseRequestHandler):
def renderPage(self, values):
directory = os.path.dirname(__file__)
path = os.path.join(directory, 'templates', 'simple_page.html')
return template.render(path, values, True)
def get(self):
page = db.get('aghwc21vZWJlbHIKCxIEUGFnZRgBDA')
#alternative code
# page db.get(db.key(self.request.get('key')))
# The solution is to call/fetch the wanted object/query
data = page.get() # or ... = Page.gql("GQL CODE").fetch(1)
values = {'page': page}
template_name = "simple_page.html"
return self.response.out.write(self.renderPage(values))
The key is just randomly taken out of my storage, it is a real existing key of a filled entity. They idea is to load a page content dynamically into the doc via AJAX, problem is, that this handler returns an empty template. No ERRORS, 200 HTTP Code, key exists etc, etc, etc. I am totally broken and a bit annoyed, by such problems, because I quiet do not know where the fault could be.
regards,
EDIT: Changing the template values to there correct names, I now get the following erro:
values = {'page': page, 'name': page.name,}
AttributeError: 'NoneType' object has no attribute 'name'