Extension

class dasha.core.Extension(*args, **kwargs)[source]

Bases: tollan.utils.namespace.Namespace

This class provides a unified interface to configure and initialize extensions using the flask factory pattern (flask extensions).

It shall be constructed via the from_dict() class method. Two items are expected:

  1. “module”. This shall be a module that defines the following two methods:

    1. init_ext. This shall be a function that takes a config dict and return a properly configured underlying flask extension object.

    2. init_app. This shall be a function that takes the underlying flask extension object and a config dict. It is called to setup the flask extension with respect to the given app.

  2. “config”. The config dict to be passed to init_ext and init_app.

Conventionally, an ObjectProxy object should be made available at the extension module level to allow convenient importing from other modules. The __wrapped__ object should be set to the underlying flask extension object at the end of init_ext.

For an example of extension module, see db

Methods Summary

init_app(self, server)

Setup the underlying extension for app.

Methods Documentation

init_app(self, server)[source]

Setup the underlying extension for app.

RuntimeError is raised if this function is called multiple times.