Base

invenio.base

Builds the Invenio application.

Wrappers

Implements the Flask application wrapper.

The function url_for() in standard Flask application changes only protocol for secure sites from ‘http’ to ‘https’. However, in case the application uses non standard ports (e.g. http://example.org:4000, https://example:4001) or even different urls (e.g. http://www.example.org, https://secure.example.org) following Flask wrapper is necessary.

Configuration:

CFG_SITE_URL specify URL under which your installation will be visible. For example, use “http://your.site.com”. Do not leave the trailing slash.
CFG_SITE_SECURE_URL specify secure URL under which your installation’s secure pages such as login or registration will be visible. For example, use “https://your.site.com”. Do not leave the trailing slash. If you don’t plan using HTTPS, then you may leave this empty.

The following example shows how to make http and https url scheme look the same.

>>> from flask import url_for
>>> from invenio.base.factory import create_app
>>> app = create_app()
>>> app.config['CFG_SITE_URL'] = 'http://localhost:4000'
>>> app.config['CFG_SITE_SECURE_URL'] = 'http://localhost:4000'
>>> ctx = app.test_request_context()
>>> ctx.push()
>>> url_for('search.search')
'/search'
>>> url_for('search.search', _external=True)
'http://localhost:4000/search'
>>> url_for('search.search', _external=True, _scheme='https')
'http://localhost:4000/search'
class invenio.base.wrappers.Flask(import_name, static_path=None, static_url_path=None, static_folder='static', template_folder='templates', instance_path=None, instance_relative_config=False)

Overriding the default Flask class.

For more information about Flask class see the official documentation of flask.Flask.

create_url_adapter(request)

Create the URL adapter.

Change behavior of default create_url_adapter method to allow advance url generation.

handle_user_exception(e)

Handle the user exception.

Hook a before handle to it.

invenio.base.wrappers.lazy_import(name)

Lazy import of the given name.

See:werkzeug.utils.import_string() and werkzeug.local.LocalProxy
Parameters:name – importable string
Returns:proxy to result of import_string()

Factory

Implements the application factory.

invenio.base.factory.create_app(instance_path=None, static_folder=None, **kwargs_config)

Prepare Invenio application based on Flask.

Invenio consists of a new Flask application with legacy support for the old WSGI legacy application and the old Python legacy scripts (URLs to *.py files).

For configuration variables detected from environment variables, a prefix will be used which is the uppercase version of the app name, excluding any non-alphabetic (‘[^A-Z]’) characters.

If instance_path is None, the <PREFIX>_INSTANCE_PATH environment variable will be used. If that one does not exist, a path inside sys.prefix will be used.

New in version 2.2: If static_folder is None, the <PREFIX>_STATIC_FOLDER environment variable will be used. If that one does not exist, a path inside the detected instance_path will be used.

invenio.base.factory.with_app_context(app=None, new_context=False, **kwargs_config)

Run function within the application context

Bundles

Base bundles.

invenio.base.bundles.invenio

Invenio JavaScript scripts

invenio.base.bundles.styles

Stylesheets such as Twitter Bootstrap, Font-Awesome, Invenio, ...

invenio.base.bundles.jquery

JavaScript libraries such as jQuery, Type Ahead, Bootstrap, Hogan, ...

Note

bootstrap.js provides $.fn.button which will be overwritten by jQueryUI button when loaded globally. Use require.js to load only the jQueryUI modules of your needs.

require(['jquery', 'ui/accordion'], function($) {
    $(function(){
        $('#accordion').accordion()
    })
})
invenio.base.bundles.lessjs

LessCSS JavaScript library that is used in debug mode to render the less stylesheets

invenio.base.bundles.requirejs

Require.js JavaScript library used in debug mode to load asynchronously the Javascript modules (defined using AMD).

invenio.base.bundles.almondjs

Require.js JavaScript library used in production mode. It cannot load asynchronously the module that must be bundles using r.js.