mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #21874 -- Require Django applications to have a filesystem path.
Wherever possible this filesystem path is derived automatically from the app module's ``__path__`` and ``__file__`` attributes (this avoids any backwards-compatibility problems). AppConfig allows specifying an app's filesystem location explicitly, which overrides all autodetection based on ``__path__`` and ``__file__``. This permits Django to support any type of module as an app (namespace packages, fake modules, modules loaded by other hypothetical non-filesystem module loaders), as long as the app is configured with an explicit filesystem path. Thanks Aymeric for review and discussion.
This commit is contained in:
parent
b87bc461c8
commit
88a2d39159
5 changed files with 102 additions and 20 deletions
|
@ -43,6 +43,8 @@ def create_egg(name, resources):
|
|||
"""
|
||||
egg = types.ModuleType(name)
|
||||
egg.__loader__ = MockLoader()
|
||||
egg.__path__ = ['/some/bogus/path/']
|
||||
egg.__file__ = '/some/bogus/path/__init__.pyc'
|
||||
egg._resources = resources
|
||||
sys.modules[name] = egg
|
||||
|
||||
|
@ -68,6 +70,9 @@ class EggLoaderTest(TestCase):
|
|||
def _get(self, path):
|
||||
return self.module._resources[path].read()
|
||||
|
||||
def _fn(self, base, resource_name):
|
||||
return resource_name
|
||||
|
||||
pkg_resources._provider_factories[MockLoader] = MockProvider
|
||||
|
||||
self.empty_egg = create_egg("egg_empty", {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue