Please review this simple code. When I review it I decide to rewrite so that it doesn't write to a template, but instead directly to output since the whole HTML is fetched from the data layer. I used the tool appengine_admin
to get editable HTML for simple html capabilities to an appspot project:
class Page(db.Model):
html = db.TextProperty(required=True)
class AdminPage(appengine_admin.ModelAdmin):
model = Page
listFields = (
'html',
)
editFields = (
'html',
)
application = webapp.WSGIApplication([ ('/page/([0-9]+)', PageHandler), ])
class PageHandler(BaseHandler):
def get(self, file_id):
page = Page.get_by_id(long(file_id))
if not page:
self.error(404)
return
self.render_template(file_id+'.html', {
'body': page.body,
})
My 2 to-dos:
- change variable
file_id
topage_id
- change writing to direct output instead of template