Skip to content

SharedDataMiddleware returns 404 for package directory access#1647

Merged
davidism merged 1 commit intomasterfrom
shared-data
Sep 20, 2019
Merged

SharedDataMiddleware returns 404 for package directory access#1647
davidism merged 1 commit intomasterfrom
shared-data

Conversation

@davidism
Copy link
Copy Markdown
Member

@davidism davidism commented Sep 20, 2019

fixes #1599

The main fix is to catch IOError when reading the data. The majority of the code change is removing the dependency on setuptools and pkg_resources in favor of the built-in pkgutils.

I tried moving to importlib_resources for Python < 3.7, but for some reason that API doesn't support directories of resources unless the directory is also a package. I'm not sure why this restriction is there, give that ResourceReader.open_resource supports directories (although is_resource doesn't). Instead, we need two versions, using theloader.get_resource_reader() API on Python 3, and the package path and loader.get_data() method on Python 2.

@davidism davidism added this to the 1.0.0 milestone Sep 20, 2019
@davidism davidism merged commit aa9676f into master Sep 20, 2019
@davidism davidism deleted the shared-data branch September 20, 2019 17:22
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SharedDataMiddleware fails with IsADirectory

1 participant