Application Startup Hooks

Application startup hooks are called when the application is created, either through a WSGI server (uWSGI or gunicorn for example) or by the flaskbb command.

Unless noted, all FlaskBB hooks are called after the relevant builtin FlaskBB setup has run (e.g. flaskbb_load_blueprints is called after all standard FlaskBB blueprints have been loaded).

The hooks below are listed in the order they are called.

flaskbb.plugins.spec.flaskbb_extensions(app)

Hook for initializing any plugin loaded extensions.

flaskbb.plugins.spec.flaskbb_load_blueprints(app)

Hook for registering blueprints.

Parameters:app – The application object.
flaskbb.plugins.spec.flaskbb_jinja_directives(app)

Hook for registering jinja filters, context processors, etc.

Parameters:app – The application object.
flaskbb.plugins.spec.flaskbb_request_processors(app)

Hook for registering pre/post request processors.

Parameters:app – The application object.
flaskbb.plugins.spec.flaskbb_errorhandlers(app)

Hook for registering error handlers.

Parameters:app – The application object.
flaskbb.plugins.spec.flaskbb_load_migrations()

Hook for registering additional migrations.

flaskbb.plugins.spec.flaskbb_load_translations()

Hook for registering translation folders.

flaskbb.plugins.spec.flaskbb_load_post_markdown_class(app)

Hook for loading a mistune renderer child class in order to render markdown on posts and user signatures. All classes returned by this hook will be composed into a single class to render markdown for posts.

Since all classes will be composed together, child classes should call super as appropriate and not add any new arguments to __init__ since the class will be insantiated with predetermined arguments.

Example:

class YellingRenderer(mistune.Renderer):
    def paragraph(self, text):
        return super(YellingRenderer, self).paragraph(text.upper())

@impl
def flaskbb_load_post_markdown_class():
    return YellingRenderer
Parameters:app (Flask) – The application object associated with the class if needed
flaskbb.plugins.spec.flaskbb_load_nonpost_markdown_class(app)

Hook for loading a mistune renderer child class in order to render markdown in locations other than posts, for example in category or forum descriptions. All classes returned by this hook will be composed into a single class to render markdown for nonpost content (e.g. forum and category descriptions).

Since all classes will be composed together, child classes should call super as appropriate and not add any new arguments to __init__ since the class will be insantiated with predetermined arguments.

Example:

class YellingRenderer(mistune.Renderer):
    def paragraph(self, text):
        return super(YellingRenderer, self).paragraph(text.upper())

@impl
def flaskbb_load_nonpost_markdown_class():
    return YellingRenderer
Parameters:app (Flask) – The application object associated with the class if needed
flaskbb.plugins.spec.flaskbb_additional_setup(app, pluggy)

Hook for any additional setup a plugin wants to do after all other application setup has finished.

For example, you could apply a WSGI middleware:

@impl
def flaskbb_additional_setup(app):
    app.wsgi_app = ProxyFix(app.wsgi_app)
Parameters:
  • app – The application object.
  • pluggy – The pluggy object.