villebro commented on code in PR #35259:
URL: https://github.com/apache/superset/pull/35259#discussion_r2524803745


##########
superset/core/api/core_api_injection.py:
##########
@@ -0,0 +1,180 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Core API Dependency Injection
+
+This module handles the injection of concrete Superset implementations
+into the abstract superset-core API modules. This allows the core API
+to be used with direct imports while maintaining loose coupling.
+"""
+
+from typing import Any, TYPE_CHECKING
+
+from sqlalchemy.orm import scoped_session
+
+if TYPE_CHECKING:
+    from superset_core.api.models import Database
+    from superset_core.api.rest_api import RestApi
+
+
+__all__ = ["initialize_core_api_dependencies"]
+
+
+def inject_dao_implementations() -> None:
+    """
+    Replace abstract DAO classes in superset_core.api.daos with concrete
+    implementations from Superset.
+    """
+    import superset_core.api.daos as core_dao_module
+
+    from superset.daos.chart import ChartDAO as HostChartDAO
+    from superset.daos.dashboard import DashboardDAO as HostDashboardDAO
+    from superset.daos.database import DatabaseDAO as HostDatabaseDAO
+    from superset.daos.dataset import DatasetDAO as HostDatasetDAO
+    from superset.daos.key_value import KeyValueDAO as HostKeyValueDAO
+    from superset.daos.query import (
+        QueryDAO as HostQueryDAO,
+        SavedQueryDAO as HostSavedQueryDAO,
+    )
+    from superset.daos.tag import TagDAO as HostTagDAO
+    from superset.daos.user import UserDAO as HostUserDAO
+
+    # Replace abstract classes with concrete implementations
+    core_dao_module.DatasetDAO = HostDatasetDAO  # type: 
ignore[assignment,misc]
+    core_dao_module.DatabaseDAO = HostDatabaseDAO  # type: 
ignore[assignment,misc]
+    core_dao_module.ChartDAO = HostChartDAO  # type: ignore[assignment,misc]
+    core_dao_module.DashboardDAO = HostDashboardDAO  # type: 
ignore[assignment,misc]
+    core_dao_module.UserDAO = HostUserDAO  # type: ignore[assignment,misc]
+    core_dao_module.QueryDAO = HostQueryDAO  # type: ignore[assignment,misc]
+    core_dao_module.SavedQueryDAO = HostSavedQueryDAO  # type: 
ignore[assignment,misc]
+    core_dao_module.TagDAO = HostTagDAO  # type: ignore[assignment,misc]
+    core_dao_module.KeyValueDAO = HostKeyValueDAO  # type: 
ignore[assignment,misc]
+
+    core_dao_module.__all__ = [
+        "DatasetDAO",
+        "DatabaseDAO",
+        "ChartDAO",
+        "DashboardDAO",
+        "UserDAO",
+        "QueryDAO",
+        "SavedQueryDAO",
+        "TagDAO",
+        "KeyValueDAO",
+    ]
+
+
+def inject_model_implementations() -> None:
+    """
+    Replace abstract model classes in superset_core.api.models with concrete
+    implementations from Superset.
+
+    Uses in-place replacement to maintain single import location for 
extensions.
+    """
+    import superset_core.api.models as core_models_module

Review Comment:
   What's your suggestion?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to