Recent entries in the sidebar
October 25, 2008
You can now see recent entries in the sidebar. Doing something like this in Django would have been a pain and likely involve complicated template tags. Using a framework with class based views means I can fetch the recent entries in my main class which is inherited by all other classes and suddenly every single page on this blog has my recent entries:
class BaseRequestHandler(webapp.RequestHandler): def render(self, template_file, extra_context={}): extra_context['request'] = self.request extra_context['admin'] = users.is_current_user_admin() extra_context['recent_entries'] = self.get_recent_entries() path = os.path.join(os.path.dirname(__file__), template_file) self.response.out.write(template.render(path, extra_context))