airflow.providers.fab.www.extensions.init_appbuilder
¶
Module Contents¶
Classes¶
This is the base class for all the framework. |
Functions¶
|
Will dynamically import a class from a string path. |
|
Init Flask App Builder. |
Attributes¶
- 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')[source]¶
This is the base class for all the framework.
- property app_icon[source]¶
Get the App icon location.
- Returns
String with relative app icon location
- property version[source]¶
Get the current F.A.B. version.
- Returns
String with the current F.A.B. version
- baseviews: list[flask_appbuilder.BaseView | sqlalchemy.orm.Session] = [][source]¶
- init_app(app, session)[source]¶
Will initialize the Flask app, supporting the app factory pattern.
- Parameters
app –
session – The SQLAlchemy session
- 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 returnsTrue
, then this link will be a part of the menu. Otherwise, it will not be included in the menu items. Defaults toNone
, 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_link(name, href, icon='', label='', category='', category_icon='', category_label='', baseview=None, cond=None)[source]¶
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 returnsTrue
, then this link will be a part of the menu. Otherwise, it will not be included in the menu items. Defaults toNone
, 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 returnsTrue
, then this separator will be a part of the menu. Otherwise, it will not be included in the menu items. Defaults toNone
, meaning the separator will always be present.
Add your views without creating a menu.
- Parameters
baseview – A BaseView type class instantiated.
- airflow.providers.fab.www.extensions.init_appbuilder.init_appbuilder(app)[source]¶
Init Flask App Builder.