You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/11/18 16:24:21 UTC

[GitHub] [airflow] ashb commented on a change in pull request #19667: Add FAB base class and set import_name explicitly.

ashb commented on a change in pull request #19667:
URL: https://github.com/apache/airflow/pull/19667#discussion_r752411285



##########
File path: airflow/www/extensions/init_appbuilder.py
##########
@@ -15,11 +15,623 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from flask_appbuilder import AppBuilder
+# This product contains a modified portion of 'Flask App Builder' developed by Daniel Vaz Gaspar.
+# (https://github.com/dpgaspar/Flask-AppBuilder).
+# Copyright 2013, Daniel Vaz Gaspar
+
+
+import logging
+from functools import reduce
+from typing import Dict
+
+from flask import Blueprint, current_app, url_for
+from flask_appbuilder import __version__
+from flask_appbuilder.api.manager import OpenApiManager
+from flask_appbuilder.babel.manager import BabelManager
+from flask_appbuilder.const import (
+    LOGMSG_ERR_FAB_ADD_PERMISSION_MENU,
+    LOGMSG_ERR_FAB_ADD_PERMISSION_VIEW,
+    LOGMSG_ERR_FAB_ADDON_IMPORT,
+    LOGMSG_ERR_FAB_ADDON_PROCESS,
+    LOGMSG_INF_FAB_ADD_VIEW,
+    LOGMSG_INF_FAB_ADDON_ADDED,
+    LOGMSG_WAR_FAB_VIEW_EXISTS,
+)
+from flask_appbuilder.filters import TemplateFilters
+from flask_appbuilder.menu import Menu, MenuApiManager
+from flask_appbuilder.views import IndexView, UtilView
 
 from airflow import settings
 from airflow.configuration import conf
 
+log = logging.getLogger(__name__)
+
+
+def dynamic_class_import(class_path):
+    """
+    Will dynamically import a class from a string path
+    :param class_path: string with class path
+    :return: class
+    """
+    # Split first occurrence of path
+    try:
+        tmp = class_path.split(".")
+        module_path = ".".join(tmp[0:-1])
+        package = __import__(module_path)
+        return reduce(getattr, tmp[1:], package)
+    except Exception as e:
+        log.exception(e)
+        log.error(LOGMSG_ERR_FAB_ADDON_IMPORT.format(class_path, e))
+
+
+class AirflowAppBuilder:
+    """
+    This is the base class for all the framework.
+    This is were you will register all your views
+    and create the menu structure.
+    Will hold your flask app object, all your views, and security classes.
+    initialize your application like this for SQLAlchemy::

Review comment:
       These are all as-is from Flask-AppBuilder and in this PR we are pulling it all in without changes.
   
   So yes, but not in this PR.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org