Author: SmileyChris
Date: 2012-02-21 16:42:19 -0800 (Tue, 21 Feb 2012)
New Revision: 17571

Modified:
   django/trunk/django/conf/__init__.py
   django/trunk/tests/regressiontests/settings_tests/tests.py
   django/trunk/tests/regressiontests/templates/tests.py
Log:
Don't let ALLOWED_INCLUDE_ROOTS be accidentally set to a string rather than a 
tuple. Thanks to Florian Apolloner for pointing this out.

Modified: django/trunk/django/conf/__init__.py
===================================================================
--- django/trunk/django/conf/__init__.py        2012-02-21 23:54:02 UTC (rev 
17570)
+++ django/trunk/django/conf/__init__.py        2012-02-22 00:42:19 UTC (rev 
17571)
@@ -73,6 +73,9 @@
         elif name == "ADMIN_MEDIA_PREFIX":
             warnings.warn("The ADMIN_MEDIA_PREFIX setting has been removed; "
                           "use STATIC_URL instead.", DeprecationWarning)
+        elif name == "ALLOWED_INCLUDE_ROOTS" and isinstance(value, basestring):
+            raise ValueError("The ALLOWED_INCLUDE_ROOTS setting must be set "
+                "to a tuple, not a string.")
         object.__setattr__(self, name, value)
 
 
@@ -98,7 +101,8 @@
         for setting in dir(mod):
             if setting == setting.upper():
                 setting_value = getattr(mod, setting)
-                if setting in tuple_settings and type(setting_value) == str:
+                if setting in tuple_settings and \
+                        isinstance(setting_value, basestring):
                     setting_value = (setting_value,) # In case the user forgot 
the comma.
                 setattr(self, setting, setting_value)
 

Modified: django/trunk/tests/regressiontests/settings_tests/tests.py
===================================================================
--- django/trunk/tests/regressiontests/settings_tests/tests.py  2012-02-21 
23:54:02 UTC (rev 17570)
+++ django/trunk/tests/regressiontests/settings_tests/tests.py  2012-02-22 
00:42:19 UTC (rev 17571)
@@ -150,6 +150,13 @@
     def test_settings_delete_wrapped(self):
         self.assertRaises(TypeError, delattr, settings, '_wrapped')
 
+    def test_allowed_include_roots_string(self):
+        """
+        ALLOWED_INCLUDE_ROOTS is not allowed to be incorrectly set to a string
+        rather than a tuple.
+        """
+        self.assertRaises(ValueError, setattr, settings,
+            'ALLOWED_INCLUDE_ROOTS', '/var/www/ssi/')
 
 
 class TrailingSlashURLTests(TestCase):

Modified: django/trunk/tests/regressiontests/templates/tests.py
===================================================================
--- django/trunk/tests/regressiontests/templates/tests.py       2012-02-21 
23:54:02 UTC (rev 17570)
+++ django/trunk/tests/regressiontests/templates/tests.py       2012-02-22 
00:42:19 UTC (rev 17571)
@@ -425,7 +425,9 @@
 
         #Set ALLOWED_INCLUDE_ROOTS so that ssi works.
         old_allowed_include_roots = settings.ALLOWED_INCLUDE_ROOTS
-        settings.ALLOWED_INCLUDE_ROOTS = 
os.path.dirname(os.path.abspath(__file__))
+        settings.ALLOWED_INCLUDE_ROOTS = (
+            os.path.dirname(os.path.abspath(__file__)),
+        )
 
         # Warm the URL reversing cache. This ensures we don't pay the cost
         # warming the cache during one of the tests.

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

Reply via email to