Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when no layout is present. #294

Merged
merged 3 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,15 @@ def dispatch(self):
return self.callback_map[target_id]['callback'](*args)

def _setup_server(self):
# Make sure `layout` is set before running the server
value = getattr(self, 'layout')
if value is None:
raise exceptions.NoLayoutException(
''
'The layout was `None` '
'at the time that `run_server` was called. '
'Make sure to set the `layout` attribute of your application '
'before running the server.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ned2 Brought a good point in #286, anything in run_server won't be run by wsgi since it's called in if __name__ == '__main__':. Should move that check to _setup_server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, looks like it will also work in _setup_server

self._generate_scripts_html()
self._generate_css_dist_html()

Expand Down
4 changes: 4 additions & 0 deletions dash/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ class DashException(Exception):
pass


class NoLayoutException(DashException):
pass


class CallbackException(DashException):
pass

Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ six
plotly>=2.0.8
requests[security]
flake8
pylint
pylint==1.9.2