pythonbottle

What's wrong with bottle.py template paths?


I'm trying to add internationalization to my page. Let's say, the route is /RU/index

@route('/<path>/<page:re:.*>')
def callback(path, page):
    fullpath = ('/%s/%s.html' % (path, page))
    print('fullpath %s' % fullpath)
    return template(fullpath)

Why doesn't it return template from file in /views/RU/index.html?


Solution

  • Just add path to TEMPLATE_PATH

    def bottle_monkeypatch():
        """
        This adds /common folder to bottle template path, thus
        makes templating cleaner and more manageable.
        """
        from bottle import TEMPLATE_PATH
        global TEMPLATE_PATH
        TEMPLATE_PATH.insert(0, './views/common')