-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make SharedDataMiddleware respect order of exports #1197
Conversation
Would you rebase against master? We fixed the tests. |
Wait, what happened? I rebased and pushed to your branch and it wiped all the changes and closed it. There's no option to reopen. |
OK, sorry, I messed up and pushed the rebase without your changes, and GitHub won't let me push again because it thinks the pr is closed(?). I'll make a new PR with your commits. |
Might be related to having the commits on master instead of a separate branch. |
The
SharedDataMiddleware
(andserving.run_simple(static_files=...)
respectively) takes a dict, mapping file and directory names in the URL to files, directories or modules on disk. However, there are no dict-lookups involved in that logic, but instead dict item's are iterated, until a first match is found. But since dict items are retrieved in arbitrary order, the behavior is unpredictable, in scenarios like this:If the key
/
is yielded first, all requests resolve toindex.html
. Even using anOrderedDict
doesn't help, since theSharedDataMiddleware
internally creates anotherdict
.It seems to make most sense to just use lists, both to be passed in when using the API, and for the internal data structure. However, for backwards compatibility I keep supporting dict-like objects as well, in this PR.