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

Fix Pages not_found_404 parsing #2100

Merged
merged 5 commits into from Jul 11, 2022
Merged

Fix Pages not_found_404 parsing #2100

merged 5 commits into from Jul 11, 2022

Conversation

jacobswe
Copy link
Contributor

@jacobswe jacobswe commented Jun 19, 2022

When initializing the Dash object using use_pages=True and pages_folder="" you cannot pass a dash.register_page("not_found_404", layout=CUSTOM_404_LAYOUT). Line 2245 joins on a pages_folder and 404 path making the searched module name ".not_found_404". This small edit fixes the error and allows for passing a 404 page using module name "not_found_404" in the case of pages_folder="". Currently, you can (outside documentation) pass ".not_found_404" with a custom layout.

Start with a description of this PR. Then edit the list below to the items that make sense for your PR scope, and check off the boxes as you go!

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Fix filepath parsing in pages 404
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

When initializing the Dash object using `use_pages=True` and `pages_folder=""` you cannot pass a `dash.register_page("not_found_404", layout=CUSTOM_404_LAYOUT)`. Line 2245 joins on a pages_folder and 404 path making the searched module name ".not_found_404". This small edit fixes the error and allows for passing a 404 page using module name "not_found_404" in the case of pages_folder="".
@jacobswe
Copy link
Contributor Author

I have been migrating my app to 3.5 and, in using the new pages plugin, I manually registered pages after doing some set up (hence the page_folder=""). I noticed couldn't pass the not_found_404 and get it to register correctly, but drilling into the source code I found this would fix the issue, and that using ".not_found_404" as the module name was a working alternative. Opening this to offer a solution (if it's not purposeful behavior) or alternatively that this would be good to document (if it is purposeful behavior).

@alexcjohnson
Copy link
Contributor

Nice catch @jacobswe! Would you be able to add this case to a test? Perhaps pala001 via get_app?

@jacobswe
Copy link
Contributor Author

Yep! Will write this and update PR over the weekend.

Copy link
Contributor

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃 Looks great, thanks @jacobswe and @AnnMarieW!

@jacobswe
Copy link
Contributor Author

Thanks for this, I was having dev environment issues and have been traveling for work.

@alexcjohnson alexcjohnson merged commit e0778c1 into plotly:dev Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants