Flask application initialization.

        :param app: The Flask application.
970311
def init_app(self, app):
        
        self.init_config(app)

        # Install datetime helpers.
        app.jinja_env.filters.update(
            from_isodate=from_isodate,
            from_isodatetime=from_isodatetime,
            to_arrow=to_arrow,
            format_arrow=format_arrow,
        )

        if app.config['FORMATTER_BADGES_ENABLE']:
            from invenio_formatter.context_processors.badges import \
                badges_processor

            # Registration of context processors.
            app.context_processor(badges_processor)
            # Register blueprint.
            app.register_blueprint(create_badge_blueprint(
                app.config['FORMATTER_BADGES_ALLOWED_TITLES']))

        app.extensions['invenio-formatter'] = self
797605
def initialize_app(flask_app, args):
    """"""
    # Setup gourde with the args.
    gourde.setup(args)

    # Register a custom health check.
    gourde.is_healthy = is_healthy

    # Add an optional API
    initialize_api(flask_app)
1191282
def init_app(self, app):
        
        app.config.setdefault('FLASK_AUTH_ALL', False)
        app.config.setdefault('FLASK_AUTH_REALM', 'Login Required')
        # Default set to bad file to trigger IOError
        app.config.setdefault('FLASK_HTPASSWD_PATH', '/^^^/^^^')

        # Load up user database
        try:
            self.load_users(app)
        except IOError:
            log.critical(
                'No htpasswd file loaded, please set `FLASK_HTPASSWD`'
                'or `FLASK_HTPASSWD_PATH` environment variable to a '
                'valid apache htpasswd file.'
            )

        # Allow requiring auth for entire app, with pre request method
        @app.before_request
        def require_auth():  # pylint: disable=unused-variable
            """Pre request processing for enabling full app authentication."""
            if not current_app.config['FLASK_AUTH_ALL']:
                return
            is_valid, user = self.authenticate()
            if not is_valid:
                return self.auth_failed()
            g.user = user
177948
def init_app(self, app):
        
        app.config.setdefault('PRETTIFY', False)

        if app.config['PRETTIFY']:
            app.after_request(self._prettify_response)
980243
def init_app(self, app):
        
        app.url_rule_class = partial(NavigationRule, copilot=self)
        app.context_processor(self.inject_context)
650732
def init_app(self, app):
        

        self.init_blueprint(app)

        if self.flaskcache is not None:
            for func, extension_name in self.CACHED:
                func = getattr(self._extensions[extension_name], func)
                setattr(
                    self._extensions[extension_name],
                    func.__name__,
                    self.flaskcache.memoize()(func)
                )

        return self.blueprint
713218
def init_app(self, app):
        
        if (
            'SQLALCHEMY_DATABASE_URI' not in app.config and
            'SQLALCHEMY_BINDS' not in app.config
        ):
            warnings.warn(
                'Neither SQLALCHEMY_DATABASE_URI nor SQLALCHEMY_BINDS is set. '
                'Defaulting SQLALCHEMY_DATABASE_URI to "sqlite:///:memory:".'
            )

        app.config.setdefault('SQLALCHEMY_DATABASE_URI', 'sqlite:///:memory:')
        app.config.setdefault('SQLALCHEMY_BINDS', None)
        app.config.setdefault('SQLALCHEMY_NATIVE_UNICODE', None)
        app.config.setdefault('SQLALCHEMY_ECHO', False)
        app.config.setdefault('SQLALCHEMY_RECORD_QUERIES', None)
        app.config.setdefault('SQLALCHEMY_POOL_SIZE', None)
        app.config.setdefault('SQLALCHEMY_POOL_TIMEOUT', None)
        app.config.setdefault('SQLALCHEMY_POOL_RECYCLE', None)
        app.config.setdefault('SQLALCHEMY_MAX_OVERFLOW', None)
        app.config.setdefault('SQLALCHEMY_COMMIT_ON_TEARDOWN', False)
        track_modifications = app.config.setdefault(
            'SQLALCHEMY_TRACK_MODIFICATIONS', None
        )
        app.config.setdefault('SQLALCHEMY_ENGINE_OPTIONS', {})

        if track_modifications is None:
            warnings.warn(FSADeprecationWarning(
                'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
                'will be disabled by default in the future.  Set it to True '
                'or False to suppress this warning.'
            ))

        # Deprecation warnings for config keys that should be replaced by SQLALCHEMY_ENGINE_OPTIONS.
        utils.engine_config_warning(app.config, '3.0', 'SQLALCHEMY_POOL_SIZE', 'pool_size')
        utils.engine_config_warning(app.config, '3.0', 'SQLALCHEMY_POOL_TIMEOUT', 'pool_timeout')
        utils.engine_config_warning(app.config, '3.0', 'SQLALCHEMY_POOL_RECYCLE', 'pool_recycle')
        utils.engine_config_warning(app.config, '3.0', 'SQLALCHEMY_MAX_OVERFLOW', 'max_overflow')

        app.extensions['sqlalchemy'] = _SQLAlchemyState(self)

        @app.teardown_appcontext
        def shutdown_session(response_or_exc):
            if app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN']:
                if response_or_exc is None:
                    self.session.commit()

            self.session.remove()
            return response_or_exc
662725
def init_app(self, app):
        
        if not hasattr(app, 'extensions'):
            app.extensions = {}

        service_name = app.config.get('GSSAPI_SERVICE_NAME', 'HTTP')
        hostname = app.config.get('GSSAPI_HOSTNAME', socket.getfqdn())
        principal = '{}@{}'.format(service_name, hostname)
        name = gssapi.Name(principal, gssapi.NameType.hostbased_service)

        app.extensions['gssapi'] = {
            'creds': gssapi.Credentials(name=name, usage='accept'),
        }
963331
def init_app(self, app):
        
        app.config.setdefault('EDITS_URL', '/edits')
        app.config.setdefault('EDITS_PREVIEW', True)
        app.config.setdefault('EDITS_SUMMERNOTE', False)

        if 'EDITS_PATH' not in app.config:
            raise Exception('EDITS_PATH not set in app configuration.')

        if os.path.isfile(app.config['EDITS_PATH']):
            with open(app.config['EDITS_PATH']) as f:
                _db = json.loads(f.read(), object_pairs_hook=OrderedDict)
        else:
            _db = OrderedDict()

        app.jinja_env.add_extension('flask.ext.edits.EditableExtension')
        app.jinja_env.edits = _db
        app.jinja_env.edits_preview = app.config['EDITS_PREVIEW']
        app.jinja_env.edits_cache = copy_cache(app.jinja_env.cache)

        if app.config['EDITS_PREVIEW']:
            app.jinja_env.cache = None

        app.register_blueprint(edits, url_prefix=app.config['EDITS_URL'])
645438
def init_app(self, app):
        
        if self._route is None:
            raise TypeError(
                "route is a required argument when app is not None")

        app.rak = self
        app.add_url_rule(self._route, view_func=getattr(self, self._view_name), methods=['POST'])
648208
def init_app(app, *storages):
    '''
    
    '''

    # Set default configuration
    app.config.setdefault('FS_SERVE', app.config.get('DEBUG', False))
    app.config.setdefault('FS_ROOT', join(app.instance_path, 'fs'))
    app.config.setdefault('FS_PREFIX', None)
    app.config.setdefault('FS_URL', None)
    app.config.setdefault('FS_BACKEND', DEFAULT_BACKEND)
    app.config.setdefault('FS_IMAGES_OPTIMIZE', False)

    state = app.extensions['fs'] = app.extensions.get('fs', {})
    for storage in storages:
        storage.configure(app)
        state[storage.name] = storage

    from .views import bp
    app.register_blueprint(bp, url_prefix=app.config['FS_PREFIX'])
265372
def init_app(self, app):
        
        state = self.init_mail(app.config, app.debug, app.testing)

        # register extension with app
        app.extensions = getattr(app, 'extensions', {})
        app.extensions['mail'] = state
        return state
1225931
def init_app(self, app, **kwargs):
        
        self.app = app

        self._init_extension()

        self.app.before_request(self.check_implicit_rules)

        if kwargs.get('ensure_authorization', False):
            self.app.after_request(self.check_authorization)
39243
def init_app(self, app):
        
        self.__init__(aws_access_key_id=app.config.get("SES_AWS_ACCESS_KEY"),
                      aws_secret_access_key=app.config.get("SES_AWS_SECRET_KEY"),
                      region=app.config.get("SES_REGION", "us-east-1"),
                      sender=app.config.get("SES_SENDER", None),
                      reply_to=app.config.get("SES_REPLY_TO", None),
                      template=app.config.get("SES_TEMPLATE", None),
                      template_context=app.config.get("SES_TEMPLATE_CONTEXT", {})
        )
43554
def init_app(self, app):
        
        app.config.setdefault('OPENERP_SERVER', 'http://localhost:8069')
        app.config.setdefault('OPENERP_DATABASE', 'openerp')
        app.config.setdefault('OPENERP_DEFAULT_USER', 'admin')
        app.config.setdefault('OPENERP_DEFAULT_PASSWORD', 'admin')

        app.jinja_env.globals.update(
            get_data_from_record=get_data_from_record
        )

        cnx = Client(
            server=app.config['OPENERP_SERVER'],
            db=app.config['OPENERP_DATABASE'],
            user=app.config['OPENERP_DEFAULT_USER'],
            password=app.config['OPENERP_DEFAULT_PASSWORD']
        )

        self.default_user = cnx.user

        app.before_request(self.before_request)
1162409
def init_app(self, app):
        
        # If no version path was provided in the init of the Dockerflow
        # class we'll use the parent directory of the app root path.
        if self.version_path is None:
            self.version_path = os.path.dirname(app.root_path)

        for view in (
            ('/__version__', 'version', self._version_view),
            ('/__heartbeat__', 'heartbeat', self._heartbeat_view),
            ('/__lbheartbeat__', 'lbheartbeat', self._lbheartbeat_view),
        ):
            self._blueprint.add_url_rule(*view)
        self._blueprint.before_app_request(self._before_request)
        self._blueprint.after_app_request(self._after_request)
        self._blueprint.app_errorhandler(HeartbeatFailure)(self._heartbeat_exception_handler)
        app.register_blueprint(self._blueprint)
        got_request_exception.connect(self._got_request_exception, sender=app)

        if not hasattr(app, 'extensions'):  # pragma: nocover
            app.extensions = {}
        app.extensions['dockerflow'] = self
602045
def after_init_app(self, app: FlaskUnchained):
        
        self.set_json_encoder(app)
        app.before_first_request(self.register_model_resources)