Add initial/basic support for configuring "included views"
also stub for managing "poser views"
This commit is contained in:
parent
33abeb1aca
commit
66a15fb9a1
6 changed files with 334 additions and 6 deletions
|
@ -27,21 +27,42 @@ App Menus
|
|||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import re
|
||||
import logging
|
||||
|
||||
from rattail.util import import_module_path, prettify
|
||||
from rattail.util import import_module_path, prettify, simple_error
|
||||
|
||||
from webhelpers2.html import tags, HTML
|
||||
|
||||
from tailbone.db import Session
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def make_simple_menus(request):
|
||||
"""
|
||||
Build the main menu list for the app.
|
||||
"""
|
||||
# first try to make menus from config
|
||||
raw_menus = make_menus_from_config(request)
|
||||
# first try to make menus from config, but this is highly
|
||||
# susceptible to failure, so try to warn user of problems
|
||||
raw_menus = None
|
||||
try:
|
||||
raw_menus = make_menus_from_config(request)
|
||||
except Exception as error:
|
||||
# TODO: these messages show up multiple times on some pages?!
|
||||
# that must mean the BeforeRender event is firing multiple
|
||||
# times..but why?? seems like there is only 1 request...
|
||||
log.warning("failed to make menus from config", exc_info=True)
|
||||
request.session.flash(simple_error(error), 'error')
|
||||
request.session.flash("Menu config is invalid! Reverting to menus "
|
||||
"defined in code!", 'warning')
|
||||
msg = HTML.literal('Please edit your {} ASAP.'.format(
|
||||
tags.link_to("Menu Config", request.route_url('configure_menus'))))
|
||||
request.session.flash(msg, 'warning')
|
||||
|
||||
if not raw_menus:
|
||||
|
||||
# no config, so import/invoke function to build them
|
||||
# no config, so import/invoke code function to build them
|
||||
menus_module = import_module_path(
|
||||
request.rattail_config.require('tailbone', 'menus'))
|
||||
if not hasattr(menus_module, 'simple_menus') or not callable(menus_module.simple_menus):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue