Beispiel #1
0
def config_loader(app, **kwargs_config):
    """Configuration loader."""
    invenio_config_loader(app, **kwargs_config)

    # TODO: Move this to invenio_cache.ext.InvenioCache.init_app
    app.jinja_env.cache_size = 1000
    app.jinja_env.bytecode_cache = BytecodeCache(app)
Beispiel #2
0
def test_bccache(base_app, ext):
    """Test bytecode cache."""
    app = base_app
    app.jinja_options = dict(app.jinja_options,
                             cache_size=1000,
                             bytecode_cache=BytecodeCache(app))

    @app.route('/')
    def view():
        return render_template('template.html', msg='test')

    with app.test_client() as c:
        assert c.get('/').get_data(as_text=True) == 'test'
Beispiel #3
0
def config_loader(app, **kwargs_config):
    """Add loading templates."""
    local_templates_path = os.path.join(app.instance_path, 'templates')
    if os.path.exists(local_templates_path):
        app.jinja_loader = ChoiceLoader([
            FileSystemLoader(local_templates_path),
            app.jinja_loader,
        ])

    app.jinja_options = dict(
        app.jinja_options,
        cache_size=1000,
        bytecode_cache=BytecodeCache(app)
    )

    app.url_map.strict_slashes = False
    invenio_config_loader(app, **kwargs_config)
Beispiel #4
0
def config_loader(app, **kwargs_config):
    """Configuration loader.

    Adds support for loading templates from the Flask application's instance
    folder (``<instance_folder>/templates``).
    """
    # This is the only place customize the Flask application right after
    # it has been created, but before all extensions etc are loaded.
    local_templates_path = os.path.join(app.instance_path, 'templates')
    if os.path.exists(local_templates_path):
        # Let's customize the template loader to look into packages
        # and application templates folders.
        app.jinja_loader = ChoiceLoader([
            FileSystemLoader(local_templates_path),
            app.jinja_loader,
        ])

    app.jinja_options = dict(app.jinja_options,
                             cache_size=1000,
                             bytecode_cache=BytecodeCache(app))

    invenio_config_loader(app, **kwargs_config)