santoshmallah opened a new issue, #23424: URL: https://github.com/apache/superset/issues/23424
I have written custom API in superset_config.py file in the custom security manager of apache superset. ```python @expose('/download_dataset/<int:dataset_id>/xlsx/') def download_dataset_xlsx(self, dataset_id): # Code to download dataset in XLSX format query = db.session.query(Query).filter_by(datasource_id=dataset_id).first() if not query: raise NotFound() result_set = db.session.query(ResultSet).filter_by(query_id=query.id).first() if not result_set: raise NotFound() df = pd.read_msgpack(result_set.data) output = io.BytesIO() writer = pd.ExcelWriter(output, engine='xlsxwriter') df.to_excel(writer, sheet_name='Sheet1', index=False) writer.save() output.seek(0) response = Response() response.data = output.read() response.headers['Content-Disposition'] = 'attachment; filename="dataset.xlsx"' response.mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' return response ``` after adding this I am getting this error ```error Found but failed to import local superset_config Traceback (most recent call last): File "c:\superset\venv\lib\site-packages\superset\config.py", line 1355, in <module> import superset_config File "C:\Users\Santosh Mallah\AppData\Local\Programs\Python\superset_config.py", line 189, in <module> from security import OIDCSecurityManager File "C:\Users\Santosh Mallah\AppData\Local\Programs\Python\security.py", line 12, in <module> from superset.models.sql_lab import Query, ResultSet File "c:\superset\venv\lib\site-packages\superset\models\__init__.py", line 17, in <module> from . import core, datasource_access_request, dynamic_plugins, sql_lab, user_attributes File "c:\superset\venv\lib\site-packages\superset\models\core.py", line 56, in <module> from superset import app, db_engine_specs, is_feature_enabled File "c:\superset\venv\lib\site-packages\superset\db_engine_specs\__init__.py", line 43, in <module> from superset.db_engine_specs.base import BaseEngineSpec File "c:\superset\venv\lib\site-packages\superset\db_engine_specs\base.py", line 64, in <module> from superset.models.sql_lab import Query File "c:\superset\venv\lib\site-packages\superset\models\sql_lab.py", line 54, in <module> class Query(Model, ExtraJSONMixin): File "c:\superset\venv\lib\site-packages\superset\models\sql_lab.py", line 112, in Query user = relationship(security_manager.user_model, foreign_keys=[user_id]) AttributeError: 'NoneType' object has no attribute 'user_model' Traceback (most recent call last): File "C:\superset\venv\Scripts\superset-script.py", line 33, in <module> sys.exit(load_entry_point('apache-superset==2.0.1', 'console_scripts', 'superset')()) File "C:\superset\venv\Scripts\superset-script.py", line 25, in importlib_load_entry_point return next(matches).load() File "C:\Users\Santosh Mallah\AppData\Local\Programs\Python\Python38\lib\importlib\metadata.py", line 75, in load module = import_module(match.group('module')) File "C:\Users\Santosh Mallah\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "c:\superset\venv\lib\site-packages\superset\cli\main.py", line 28, in <module> from superset.cli.lib import normalize_token File "c:\superset\venv\lib\site-packages\superset\cli\lib.py", line 20, in <module> from superset import config File "c:\superset\venv\lib\site-packages\superset\config.py", line 1355, in <module> import superset_config File "C:\Users\Santosh Mallah\AppData\Local\Programs\Python\superset_config.py", line 189, in <module> from security import OIDCSecurityManager File "C:\Users\Santosh Mallah\AppData\Local\Programs\Python\security.py", line 12, in <module> from superset.models.sql_lab import Query, ResultSet File "c:\superset\venv\lib\site-packages\superset\models\__init__.py", line 17, in <module> from . import core, datasource_access_request, dynamic_plugins, sql_lab, user_attributes File "c:\superset\venv\lib\site-packages\superset\models\core.py", line 56, in <module> from superset import app, db_engine_specs, is_feature_enabled File "c:\superset\venv\lib\site-packages\superset\db_engine_specs\__init__.py", line 43, in <module> from superset.db_engine_specs.base import BaseEngineSpec File "c:\superset\venv\lib\site-packages\superset\db_engine_specs\base.py", line 64, in <module> from superset.models.sql_lab import Query File "c:\superset\venv\lib\site-packages\superset\models\sql_lab.py", line 54, in <module> class Query(Model, ExtraJSONMixin): File "c:\superset\venv\lib\site-packages\superset\models\sql_lab.py", line 112, in Query user = relationship(security_manager.user_model, foreign_keys=[user_id]) AttributeError: 'NoneType' object has no attribute 'user_model' ``` why I am getting this error - browser type and version: - superset version: `2.0.1` - python version: `3.8.0` - node.js version: `16` - any feature flags active: ```json FEATURE_FLAGS = { 'CLIENT_CACHE': False, 'ENABLE_EXPLORE_JSON_CSRF_PROTECTION': False, # 'PRESTO_EXPAND_DATA': True, 'ENABLE_TEMPLATE_PROCESSING': True, 'ALERTS_ATTACH_REPORTS':True, 'ALLOW_ADHOC_SUBQUERY':True, 'DASHBOARD_CROSS_FILTERS':True, 'DASHBOARD_RBAC':True, 'DATASET_RBAC':True, 'DISABLE_LEGACY_DATASOURCE_EDITOR':True, 'DRUID_JOINS':True, "ALERT_REPORTS": True, 'EMBEDDABLE_CHARTS':True, 'EMBEDDED_SUPERSET':True, 'ENABLE_DND_WITH_CLICK_UX':True, 'ENABLE_EXPLORE_DRAG_AND_DROP':True, 'ENFORCE_DB_ENCRYPTION_UI':True, 'ESCAPE_MARKDOWN_HTML':True, 'LISTVIEWS_DEFAULT_CARD_VIEW':True, 'SCHEDULED_QUERIES':True, 'SQLLAB_BACKEND_PERSISTENCE':True, 'SQL_VALIDATORS_BY_ENGINE':True, 'THUMBNAILS':True, 'ROW_LEVEL_SECURITY': True, 'ALLOW_FULL_CSV_EXPORT': True, 'THUMBNAILS_SQLA_LISTENERS': True, 'DASHBOARD_FILTERS_EXPERIMENTAL': True, 'DASHBOARD_NATIVE_FILTERS': True, 'HORIZONTAL_FILTER_BAR': True, 'ENABLE_DRUID_DASHBOARDING':True, # 'ENABLE_FILTER_BOX_MIGRATION':True, 'ENABLE_ADVANCED_DATA_TYPES':True, 'DYNAMIC_PLUGINS':True, 'DASHBOARD_NATIVE_FILTERS_SET':True, 'DASHBOARD_EDIT_CHART_IN_NEW_TAB':True, 'CROSS_REFERENCES':True, 'DRILL_TO_DETAIL':True, 'FEATURE_DRILL_TO_DETAIL':True, 'UX_BETA':True, 'VERSIONED_EXPORT':True } ``` ### Checklist Make sure to follow these steps before submitting your issue - thank you! - [x ] I have checked the superset logs for python stack traces and included them here as text if there are any. - [x ] I have reproduced the issue with at least the superset's latest version. - [x ] I have checked the issue tracker for the same issue but haven't found one similar. Thanks in advance. -- 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: notifications-unsubscr...@superset.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org