Script

Initialize and configure Flask-Script extension.

Configuration

The following configuration variables are provided:

bind address Preferred binding address of the server. Can be used to select a specific interface or to bind to all via 0.0.0.0.
bind port Preferred binding port of the server. Can differ from the one stated in CFG_SITE_URL so it can be accessed via reverse proxy.

They are assigned by the following parameters, in decreasing priority:

  1. Command line arguments of inveniomanage runserver
  2. SERVER_BIND_ADDRESS and SERVER_BIND_PORT configuration
  3. Values guessed from CFG_SITE_URL
  4. Defaults (127.0.0.1:80)
class invenio.ext.script.Manager(app=None, with_default_commands=None, usage=None, help=None, description=None, disable_argcomplete=False)

Bases: flask_script.Manager

Custom manager implementation with signaling support.

add_command(name, command)

Wrap default add_command method.

invenio.ext.script.change_command_name(method=None, new_name=None)

Change command name to new_name or replace ‘_’ by ‘-‘.

invenio.ext.script.check_for_software_updates(flash_message=False)

Check for a new release of Invenio.

Returns:True if you have latest version, else False if you need to upgrade or None if server was not reachable.
invenio.ext.script.create_ssl_context(config)

Create ssl.SSLContext from application config.

Parameters:config – Dict-like application configuration.
Returns:A valid context or in case TLS is not enabled None.

The following configuration variables are processed:

SERVER_TLS_ENABLE If True, a SSL context will be created. In this case, the required configuration variables must be provided.
SERVER_TLS_KEY (required) Filepath (string) of private key provided as PEM file.
SERVER_TLS_CERT (required) Filepath (string) of your certificate plus all intermediate certificate, concatenated in that order and stored as PEM file.
SERVER_TLS_KEYPASS If private key is encrypted, a password can be provided.
SERVER_TLS_PROTOCOL String that selects a protocol from ssl.PROTOCOL_*. Defaults to SSLv23. See ssl for details.
SERVER_TLS_CIPHERS String that selects possible ciphers according to the OpenSSL cipher list format
SERVER_TLS_DHPARAMS Filepath (string) to parameters for Diffie-Helman key exchange. If not set the built-in parameters are used.
SERVER_TLS_ECDHCURVE Curve (string) that should be used for Elliptic Curve-based Diffie-Helman key exchange. If not set, the defaults provided by OpenSSL are used.

Note

In case None is returned because of a non-enabling configuration, TLS will be disabled. It is not possible to have a TLS and non-TLS configuration at the same time. So if TLS is activated, no non-TLS connection are accepted.

Important

Keep in mind to change CFG_SITE_URL and CFG_SITE_SECURE_URL according to your TLS configuration. This does not only include the protocol (http vs https) but also the hostname that has to match the common name in your certificate. If a wildcard certificate is provided, the hostname stated in CFG_SITE[_SECURE]_URL must match the wildcard pattern.

invenio.ext.script.generate_secret_key()

Generate secret key.

invenio.ext.script.print_progress(p, L=40, prefix='', suffix='')

Print textual progress bar.

invenio.ext.script.register_manager(manager)

Register all manager plugins and default commands with the manager.

invenio.ext.script.set_serve_static_files(sender, *args, **kwargs)

Enable serving of static files for runserver command.

Normally Apache serves static files, but during development and if you are using the Werkzeug standalone development server, you can set this flag to True, to enable static file serving.