Author: jezdez
Date: 2011-08-14 11:15:04 -0700 (Sun, 14 Aug 2011)
New Revision: 16617

Modified:
   django/trunk/django/contrib/staticfiles/storage.py
   django/trunk/django/contrib/staticfiles/utils.py
Log:
Fixed #16629 -- Relaxed check for STATIC_ROOT and STATIC_URL settings slightly 
to only raise an exception if really needed.

Modified: django/trunk/django/contrib/staticfiles/storage.py
===================================================================
--- django/trunk/django/contrib/staticfiles/storage.py  2011-08-13 13:51:34 UTC 
(rev 16616)
+++ django/trunk/django/contrib/staticfiles/storage.py  2011-08-14 18:15:04 UTC 
(rev 16617)
@@ -30,18 +30,18 @@
             location = settings.STATIC_ROOT
         if base_url is None:
             base_url = settings.STATIC_URL
-        if not location:
-            raise ImproperlyConfigured("You're using the staticfiles app "
-                "without having set the STATIC_ROOT setting.")
-        # check for None since we might use a root URL (``/``)
-        if base_url is None:
-            raise ImproperlyConfigured("You're using the staticfiles app "
-                "without having set the STATIC_URL setting.")
-        check_settings()
+        check_settings(base_url)
         super(StaticFilesStorage, self).__init__(location, base_url,
                                                  *args, **kwargs)
 
+    def path(self, name):
+        if not self.location:
+            raise ImproperlyConfigured("You're using the staticfiles app "
+                                       "without having set the STATIC_ROOT "
+                                       "setting to a filesystem path.")
+        return super(StaticFilesStorage, self).path(name)
 
+
 class CachedFilesMixin(object):
     patterns = (
         ("*.css", (

Modified: django/trunk/django/contrib/staticfiles/utils.py
===================================================================
--- django/trunk/django/contrib/staticfiles/utils.py    2011-08-13 13:51:34 UTC 
(rev 16616)
+++ django/trunk/django/contrib/staticfiles/utils.py    2011-08-14 18:15:04 UTC 
(rev 16617)
@@ -37,16 +37,18 @@
         for fn in get_files(storage, ignore_patterns, dir):
             yield fn
 
-def check_settings():
+def check_settings(base_url=None):
     """
     Checks if the staticfiles settings have sane values.
 
     """
-    if not settings.STATIC_URL:
+    if base_url is not None:
+        base_url = settings.STATIC_URL
+    if not base_url:
         raise ImproperlyConfigured(
             "You're using the staticfiles app "
             "without having set the required STATIC_URL setting.")
-    if settings.MEDIA_URL == settings.STATIC_URL:
+    if settings.MEDIA_URL == base_url:
         raise ImproperlyConfigured("The MEDIA_URL and STATIC_URL "
                                    "settings must have different values")
     if ((settings.MEDIA_ROOT and settings.STATIC_ROOT) and

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to