diff options
Diffstat (limited to 'django/contrib/staticfiles/storage.py')
| -rw-r--r-- | django/contrib/staticfiles/storage.py | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index 69af9ca297..ba3b62620d 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -3,18 +3,13 @@ import json import os import posixpath import re -import warnings from urllib.parse import unquote, urldefrag, urlsplit, urlunsplit from django.conf import settings from django.contrib.staticfiles.utils import check_settings, matches_patterns -from django.core.cache import ( - InvalidCacheBackendError, cache as default_cache, caches, -) from django.core.exceptions import ImproperlyConfigured from django.core.files.base import ContentFile from django.core.files.storage import FileSystemStorage, get_storage_class -from django.utils.deprecation import RemovedInDjango31Warning from django.utils.functional import LazyObject @@ -430,63 +425,6 @@ class ManifestFilesMixin(HashedFilesMixin): return urlunsplit(unparsed_name) -class _MappingCache: - """ - A small dict-like wrapper for a given cache backend instance. - """ - def __init__(self, cache): - self.cache = cache - - def __setitem__(self, key, value): - self.cache.set(key, value) - - def __getitem__(self, key): - value = self.cache.get(key) - if value is None: - raise KeyError("Couldn't find a file name '%s'" % key) - return value - - def clear(self): - self.cache.clear() - - def update(self, data): - self.cache.set_many(data) - - def get(self, key, default=None): - try: - return self[key] - except KeyError: - return default - - -class CachedFilesMixin(HashedFilesMixin): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - try: - self.hashed_files = _MappingCache(caches['staticfiles']) - except InvalidCacheBackendError: - # Use the default backend - self.hashed_files = _MappingCache(default_cache) - - def hash_key(self, name): - key = hashlib.md5(self.clean_name(name).encode()).hexdigest() - return 'staticfiles:%s' % key - - -class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage): - """ - A static file system storage backend which also saves - hashed copies of the files it saves. - """ - def __init__(self, *args, **kwargs): - warnings.warn( - 'CachedStaticFilesStorage is deprecated in favor of ' - 'ManifestStaticFilesStorage.', - RemovedInDjango31Warning, stacklevel=2, - ) - super().__init__(*args, **kwargs) - - class ManifestStaticFilesStorage(ManifestFilesMixin, StaticFilesStorage): """ A static file system storage backend which also saves |
