diff options
| author | Carl Meyer <carl@oddbird.net> | 2011-02-01 14:57:10 +0000 |
|---|---|---|
| committer | Carl Meyer <carl@oddbird.net> | 2011-02-01 14:57:10 +0000 |
| commit | 7aad3d3fa8a8db8eb8ea9e64134d60b2400029f0 (patch) | |
| tree | e940c9be08092ce944c21c07de0ef8a368578146 /django | |
| parent | 74d485c4ec2b754578482af98e3e8258d1575ad0 (diff) | |
Fixed #15094 - Added check for forgetting trailing comma in STATICFILES_DIRS tuple. Also reorganized staticfiles settings-checks for better consistency.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15386 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/staticfiles/finders.py | 8 | ||||
| -rw-r--r-- | django/contrib/staticfiles/handlers.py | 7 | ||||
| -rw-r--r-- | django/contrib/staticfiles/storage.py | 5 | ||||
| -rw-r--r-- | django/contrib/staticfiles/utils.py | 15 |
4 files changed, 17 insertions, 18 deletions
diff --git a/django/contrib/staticfiles/finders.py b/django/contrib/staticfiles/finders.py index 8d66cfe724..c3b0eb6f07 100644 --- a/django/contrib/staticfiles/finders.py +++ b/django/contrib/staticfiles/finders.py @@ -46,11 +46,19 @@ class FileSystemFinder(BaseFinder): self.storages = SortedDict() # Set of locations with static files self.locations = set() + if not isinstance(settings.STATICFILES_DIRS, (list, tuple)): + raise ImproperlyConfigured( + "Your STATICFILES_DIRS setting is not a tuple or list; " + "perhaps you forgot a trailing comma?") for root in settings.STATICFILES_DIRS: if isinstance(root, (list, tuple)): prefix, root = root else: prefix = '' + if os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root): + raise ImproperlyConfigured( + "The STATICFILES_DIRS setting should " + "not contain the STATIC_ROOT setting") self.locations.add((prefix, root)) # Don't initialize multiple storages for the same location for prefix, root in self.locations: diff --git a/django/contrib/staticfiles/handlers.py b/django/contrib/staticfiles/handlers.py index ace19f4f09..669ffaeabc 100644 --- a/django/contrib/staticfiles/handlers.py +++ b/django/contrib/staticfiles/handlers.py @@ -26,12 +26,7 @@ class StaticFilesHandler(WSGIHandler): return settings.STATIC_ROOT def get_base_url(self): - if not settings.STATIC_URL: - raise ImproperlyConfigured("You're using the staticfiles app " - "without having set the STATIC_URL setting. Set it to " - "URL that handles the files served from STATIC_ROOT.") - if settings.DEBUG: - utils.check_settings() + utils.check_settings() return settings.STATIC_URL def _should_handle(self, path): diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index d93b7e052a..ab4a364f9b 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -10,7 +10,7 @@ from django.contrib.staticfiles import utils class StaticFilesStorage(FileSystemStorage): """ Standard file system storage for static files. - + The defaults for ``location`` and ``base_url`` are ``STATIC_ROOT`` and ``STATIC_URL``. """ @@ -28,8 +28,7 @@ class StaticFilesStorage(FileSystemStorage): raise ImproperlyConfigured("You're using the staticfiles app " "without having set the STATIC_URL setting. Set it to " "URL that handles the files served from STATIC_ROOT.") - if settings.DEBUG: - utils.check_settings() + utils.check_settings() super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs) diff --git a/django/contrib/staticfiles/utils.py b/django/contrib/staticfiles/utils.py index 217bc7a706..9ff4bc4321 100644 --- a/django/contrib/staticfiles/utils.py +++ b/django/contrib/staticfiles/utils.py @@ -35,9 +35,13 @@ def get_files(storage, ignore_patterns=[], location=''): def check_settings(): """ - Checks if the MEDIA_(ROOT|URL) and STATIC_(ROOT|URL) - settings have the same value. + Checks if the staticfiles settings have sane values. + """ + if not settings.STATIC_URL: + raise ImproperlyConfigured( + "You're using the staticfiles app " + "without having set the required STATIC_URL setting.") if settings.MEDIA_URL == settings.STATIC_URL: raise ImproperlyConfigured("The MEDIA_URL and STATIC_URL " "settings must have different values") @@ -45,10 +49,3 @@ def check_settings(): (settings.MEDIA_ROOT == settings.STATIC_ROOT)): raise ImproperlyConfigured("The MEDIA_ROOT and STATIC_ROOT " "settings must have different values") - for path in settings.STATICFILES_DIRS: - # in case the item contains a prefix - if isinstance(path, (list, tuple)): - path = path[1] - if os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(path): - raise ImproperlyConfigured("The STATICFILES_DIRS setting should " - "not contain the STATIC_ROOT setting") |
