summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2014-01-25 03:57:29 -0800
committerJannis Leidel <jannis@leidel.info>2014-01-25 03:57:29 -0800
commitb9e0ea3cb4ad25f767c77cb85a05f800aefda65b (patch)
tree9a7b65ba347103d8299a6c78cfb7c9b26fcc9add /django
parent2ff93e027c7b35378cc450a926bc2e4a446cacf0 (diff)
parentf56c88a8eed91f68f6845bbf730f7b7361c5cfb1 (diff)
Merge pull request #2211 from carljm/t21867
Fixed #21867 -- Removed AppStaticStorage; app paths are now AppConfig's job.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/staticfiles/finders.py29
-rw-r--r--django/contrib/staticfiles/storage.py21
2 files changed, 13 insertions, 37 deletions
diff --git a/django/contrib/staticfiles/finders.py b/django/contrib/staticfiles/finders.py
index eed88a034e..30767405d3 100644
--- a/django/contrib/staticfiles/finders.py
+++ b/django/contrib/staticfiles/finders.py
@@ -11,7 +11,6 @@ from django.utils._os import safe_join
from django.utils import six, lru_cache
from django.contrib.staticfiles import utils
-from django.contrib.staticfiles.storage import AppStaticStorage
class BaseFinder(object):
@@ -110,24 +109,27 @@ class FileSystemFinder(BaseFinder):
class AppDirectoriesFinder(BaseFinder):
"""
A static files finder that looks in the directory of each app as
- specified in the source_dir attribute of the given storage class.
+ specified in the source_dir attribute.
"""
- storage_class = AppStaticStorage
+ storage_class = FileSystemStorage
+ source_dir = 'static'
def __init__(self, app_names=None, *args, **kwargs):
# The list of apps that are handled
self.apps = []
# Mapping of app names to storage instances
self.storages = OrderedDict()
- if app_names is None:
- app_configs = apps.get_app_configs()
- app_names = [app_config.name for app_config in app_configs]
- for app in app_names:
- app_storage = self.storage_class(app)
+ app_configs = apps.get_app_configs()
+ if app_names:
+ app_names = set(app_names)
+ app_configs = [ac for ac in app_configs if ac.name in app_names]
+ for app_config in app_configs:
+ app_storage = self.storage_class(
+ os.path.join(app_config.path, self.source_dir))
if os.path.isdir(app_storage.location):
- self.storages[app] = app_storage
- if app not in self.apps:
- self.apps.append(app)
+ self.storages[app_config.name] = app_storage
+ if app_config.name not in self.apps:
+ self.apps.append(app_config.name)
super(AppDirectoriesFinder, self).__init__(*args, **kwargs)
def list(self, ignore_patterns):
@@ -158,11 +160,6 @@ class AppDirectoriesFinder(BaseFinder):
"""
storage = self.storages.get(app, None)
if storage:
- if storage.prefix:
- prefix = '%s%s' % (storage.prefix, os.sep)
- if not path.startswith(prefix):
- return None
- path = path[len(prefix):]
# only try to find a file if the source dir actually exists
if storage.exists(path):
matched_path = storage.path(path)
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
index 9b273e3efd..ede04fc2a5 100644
--- a/django/contrib/staticfiles/storage.py
+++ b/django/contrib/staticfiles/storage.py
@@ -1,7 +1,6 @@
from __future__ import unicode_literals
from collections import OrderedDict
import hashlib
-from importlib import import_module
import os
import posixpath
import re
@@ -16,7 +15,6 @@ from django.core.files.storage import FileSystemStorage, get_storage_class
from django.utils.encoding import force_bytes, force_text
from django.utils.functional import LazyObject
from django.utils.six.moves.urllib.parse import unquote, urlsplit, urlunsplit, urldefrag
-from django.utils._os import upath
from django.contrib.staticfiles.utils import check_settings, matches_patterns
@@ -383,25 +381,6 @@ class ManifestStaticFilesStorage(ManifestFilesMixin, StaticFilesStorage):
pass
-class AppStaticStorage(FileSystemStorage):
- """
- A file system storage backend that takes an app module and works
- for the ``static`` directory of it.
- """
- prefix = None
- source_dir = 'static'
-
- def __init__(self, app, *args, **kwargs):
- """
- Returns a static file storage if available in the given app.
- """
- # app is the actual app module
- mod = import_module(app)
- mod_path = os.path.dirname(upath(mod.__file__))
- location = os.path.join(mod_path, self.source_dir)
- super(AppStaticStorage, self).__init__(location, *args, **kwargs)
-
-
class ConfiguredStorage(LazyObject):
def _setup(self):
self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()