server.config

Classes

Config

Represents the configuration of the server.

ApplicationConfig

Represents an application config entry loaded from a dictionary like

Module Contents

class server.config.Config(configuration: dict[str, Any])[source]

Represents the configuration of the server.

applications[source]
mail_queues[source]
logging[source]
classmethod from_yaml_file(yaml_file: _typeshed.StrOrBytesPath) Self[source]

Load the given yaml file and return a new Configuration instance with the configuration values found in the yaml file.

classmethod from_yaml_string(yaml_string: str | bytes) Self[source]

Load the given yaml string and return a new Configuration instance with the configuration values found in the yaml string.

class server.config.ApplicationConfig(configuration: dict[str, Any])[source]

Represents an application config entry loaded from a dictionary like this:

{
    'path': '/application',
    'application': 'my.module.StaticApp',
    'namespace': 'my-namespace'
    'configuration': {
        'my': 'custom',
        'config': 'values'
    }
}

It may contain the following keys:

Path:

The path of the application is the prefix under which the application is running. For each path onegov.server loads and caches an application.

Applications are basically WSGI containers that are run independently in the same process.

See Application for more.

There are two types of applications, static applications without a wildcard (*) in their path and wildcard applications with a wildcard in their path.

Static applications always have the same application_id (ns/static, if the path is /static and the namespace is ns).

Wildcard applications have the application_id set to the wildcard part of the path: (/wildcard/* can result in an applicaiton_id of ns/blog if /wildcard/blog is opened and the namespace is ns).

See also: set_application_id().

Nested paths are not supported. /static works and /wildcard/* works, but not /static/site or /wildcard/site/*.

Application:

The application class or string to an application class that inherits from Application.

If application is a string, the class it points to is loaded immediately.

Namespace:

Each application has a namespace that must be unique. It is used make the application_id unique. Dashes in the namespace are replaced by underscores.

Configuration:

A dictionary that is passed to the application once it is initialized. See application.Application.configure_application().

__slots__ = ('_cfg',)[source]
_cfg[source]
property path: str[source]
property namespace: str[source]
property application_class: type[server.application.Application][source]
property configuration: dict[str, Any][source]
property root: str[source]

The path without the wildcard such that /app and /app/* produce the same root (/app).

property is_static: bool[source]

True if the application is static (has no ‘*’ in the path).