airflow.providers.fab.www.extensions.init_appbuilder

Attributes

log

Classes

AirflowAppBuilder

This is the base class for all the framework.

Functions

dynamic_class_import(class_path)

Will dynamically import a class from a string path.

init_appbuilder(app, enable_plugins)

Init Flask App Builder.

Module Contents

airflow.providers.fab.www.extensions.init_appbuilder.log[source]
airflow.providers.fab.www.extensions.init_appbuilder.dynamic_class_import(class_path)[source]

Will dynamically import a class from a string path.

Parameters:

class_path – string with class path

Returns:

class

class airflow.providers.fab.www.extensions.init_appbuilder.AirflowAppBuilder(app=None, session=None, menu=None, indexview=None, base_template='airflow/main.html', static_folder='static/appbuilder', static_url_path='/appbuilder', enable_plugins=False)[source]

This is the base class for all the framework.

baseviews: list[flask_appbuilder.BaseView | sqlalchemy.orm.Session] = [][source]
app = None[source]
session = None[source]
sm: flask_appbuilder.security.manager.BaseSecurityManager[source]
bm = None[source]
addon_managers: dict[source]
menu = None[source]
indexview = None[source]
static_folder = None[source]
static_url_path = None[source]
template_filters = None[source]
base_template = 'airflow/main.html'[source]
enable_plugins = False[source]
update_perms = True[source]
auth_rate_limited = True[source]
auth_rate_limit[source]
init_app(app, session)[source]

Will initialize the Flask app, supporting the app factory pattern.

Parameters:
  • app

  • session – The SQLAlchemy session

property get_app[source]

Get current or configured flask app.

Returns:

Flask App

property get_session[source]

Get the current sqlalchemy session.

Returns:

SQLAlchemy Session

property app_name[source]

Get the App name.

Returns:

String with app name

property app_theme[source]

Get the App theme name.

Returns:

String app theme name

property app_icon[source]

Get the App icon location.

Returns:

String with relative app icon location

property languages[source]
property version[source]

Get the current F.A.B. version.

Returns:

String with the current F.A.B. version

add_view(baseview, name, href='', icon='', label='', category='', category_icon='', category_label='', menu_cond=None)[source]

Add your views associated with menus using this method.

Parameters:
  • baseview – A BaseView type class instantiated or not. This method will instantiate the class for you if needed.

  • name – The string name that identifies the menu.

  • href – Override the generated link for the menu. You can use an url string or an endpoint name if non provided default_view from view will be set as link.

  • icon – Font-Awesome icon name, optional.

  • label – The label that will be displayed on the menu, if absent param name will be used

  • category – The menu category where the menu will be included, if non provided the view will be accessible as a top menu.

  • category_icon – Font-Awesome icon name for the category, optional.

  • category_label – The label that will be displayed on the menu, if absent param name will be used

  • menu_cond – If a callable, menu_cond will be invoked when constructing the menu items. If it returns True, then this link will be a part of the menu. Otherwise, it will not be included in the menu items. Defaults to None, meaning the item will always be present.

Examples:

appbuilder = AppBuilder(app, db)
# Register a view, rendering a top menu without icon.
appbuilder.add_view(MyModelView(), "My View")
# or not instantiated
appbuilder.add_view(MyModelView, "My View")
# Register a view, a submenu "Other View" from "Other" with a phone icon.
appbuilder.add_view(MyOtherModelView, "Other View", icon="fa-phone", category="Others")
# Register a view, with category icon and translation.
appbuilder.add_view(
    YetOtherModelView,
    "Other View",
    icon="fa-phone",
    label=_("Other View"),
    category="Others",
    category_icon="fa-envelop",
    category_label=_("Other View"),
)
# Register a view whose menu item will be conditionally displayed
appbuilder.add_view(
    YourFeatureView,
    "Your Feature",
    icon="fa-feature",
    label=_("Your Feature"),
    menu_cond=lambda: is_feature_enabled("your-feature"),
)
# Add a link
appbuilder.add_link("google", href="www.google.com", icon="fa-google-plus")

Add your own links to menu using this method.

Parameters:
  • name – The string name that identifies the menu.

  • href – Override the generated link for the menu. You can use an url string or an endpoint name

  • icon – Font-Awesome icon name, optional.

  • label – The label that will be displayed on the menu, if absent param name will be used

  • category – The menu category where the menu will be included, if non provided the view will be accessible as a top menu.

  • category_icon – Font-Awesome icon name for the category, optional.

  • category_label – The label that will be displayed on the menu, if absent param name will be used

  • baseview – A BaseView type class instantiated.

  • cond – If a callable, cond will be invoked when constructing the menu items. If it returns True, then this link will be a part of the menu. Otherwise, it will not be included in the menu items. Defaults to None, meaning the item will always be present.

add_separator(category, cond=None)[source]

Add a separator to the menu, you will sequentially create the menu.

Parameters:
  • category – The menu category where the separator will be included.

  • cond – If a callable, cond will be invoked when constructing the menu items. If it returns True, then this separator will be a part of the menu. Otherwise, it will not be included in the menu items. Defaults to None, meaning the separator will always be present.

add_view_no_menu(baseview, endpoint=None, static_folder=None)[source]

Add your views without creating a menu.

Parameters:

baseview – A BaseView type class instantiated.

property get_url_for_index[source]
get_url_for_locale(lang)[source]
add_limits(baseview)[source]
add_permissions(update_perms=False)[source]
register_blueprint(baseview, endpoint=None, static_folder=None)[source]
airflow.providers.fab.www.extensions.init_appbuilder.init_appbuilder(app, enable_plugins)[source]

Init Flask App Builder.

Was this entry helpful?