Skip to content

App should raise an Exception on misconfigured view_decorator #522

Open
@spiqueras

Description

@spiqueras

If the user has provided a view_decorator, and this decorator fails to be imported, django-plotly-dash will default to no decoration as it swallows all exceptions.

try:
dash_view_decorator_name = settings.PLOTLY_DASH['view_decorator']
try:
dash_view_decorator = locals()[dash_view_decorator_name]
except:
mod_name, func_name = dash_view_decorator_name.rsplit('.', 1)
if mod_name:
mod = importlib.import_module(mod_name)
dash_view_decorator = getattr(mod, func_name)
else:
dash_view_decorator = locals()[func_name]
except:
dash_view_decorator = None

It'd be more sensible to raise an exception in such cases (maybe ImproperlyConfigured?), so the user is immediately notified of their error and can fix it. Technically a breaking change but hopefully one for the better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions