view piecrust/admin/views/__init__.py @ 1136:5f97b5b59dfe

bake: Optimize cache handling for the baking process. - Get rid of the 2-level pipeline runs... handle a single set of passes. - Go back to load/render segments/layout passes for pages. - Add descriptions of what each job batch does. - Improve the taxonomy pipeline so it doesn't re-bake terms that don't need to be re-baked. - Simplify some of the code.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 23 Apr 2018 21:47:49 -0700
parents b1a00c2c0c7f
children
line wrap: on
line source

from flask import current_app, render_template, request
from flask.views import View
from .menu import get_menu_context


class FoodTruckView(View):
    template_name = 'index.html'
    requires_menu = True

    def render_template(self, context):
        if self.requires_menu:
            context = with_menu_context()
        return render_template(self.template_name, **context)

    def get_context(self):
        return None

    def dispatch_request(self):
        ctx = self.get_context()
        return render_template(ctx)


def with_menu_context(context=None):
    if context is None:
        context = {}
    context['menu'] = get_menu_context()
    return context