superset-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] gbates101 opened a new issue #5124: Loading appbuilder views instead of flask blueprints
Date Fri, 01 Jun 2018 15:12:31 GMT
gbates101 opened a new issue #5124: Loading appbuilder views instead of flask blueprints
URL: https://github.com/apache/incubator-superset/issues/5124
 
 
   - [x] I have checked the superset logs for python stacktraces and included it here as text
if any
   - [x] I have reproduced the issue with at least the latest released version of superset
   - [x] I have checked the issue tracker for the same issue and I haven't found one similar
   
   ### Superset version
   0.25.4
   
   ### Expected results
   Writing a view from appbuilder's [BaseView](http://flask-appbuilder.readthedocs.io/en/latest/views.html)
(like superset does internally) should be loadable. Could be similar to how [ADDITIONAL_MODULE_DS_MAP](https://github.com/apache/incubator-superset/blob/cc0942ac988fc09538da14495f05411fcf2ac5e8/superset/__init__.py#L178)
config setting is used.
   
   ### Actual results
   Unless I modify source and append an import to [__init__.py](https://github.com/apache/incubator-superset/blob/cc0942ac988fc09538da14495f05411fcf2ac5e8/superset/__init__.py#L191)
to load my views, I have to rewrite my view as a [Flask blueprint](http://flask.pocoo.org/docs/1.0/blueprints/)
to import it.
   
   ### Steps to reproduce
   
   1. Create a class that extends `BaseSupersetView`.
   2. Use appbuilder API to import it.
   3. Load module as a blueprint in config.
   4. Nothing happens. It must be rewritten to use flask blueprint API.
   
   Here is the view I was working with. Creating a `Blueprint` object and adding to `BLUEPRINTS`
list in config will not load this properly, but adding an import statement at the end of __init__.py
will. 
   ```python
   from flask_appbuilder.baseviews import expose_api
   from flask_appbuilder.security.decorators import has_access_api
   from flask_babel import gettext as __
   from superset import appbuilder
   from superset.views.core import BaseSupersetView
   import plaid.superset.datasource_helpers as dh
   
   class MyView(BaseSupersetView):
       @expose_api(name='api', url='/api/refresh', methods=['GET'])
       @expose_api(name='api', url='/api/refresh/<project_id>', methods=['GET'])
       @has_access_api
       def refresh(self, project_id=None):
           if project_id:
               dh.sync_report_datasource(project_id)
           else:
               # Sync everything if no project ID specified.
               dh.sync_report_datasources()
       
   appbuilder.add_view_no_menu(Plaid)
   appbuilder.add_link(
       'Refresh',
       label=__('Refresh'),
       href='/plaid/api/refresh',
       icon='fa-refresh',
       category='Sources',
       category_label=__('Sources'),
       category_icon='fa-database')
   ```
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Mime
View raw message