Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't let ALLOWED_INCLUDE_ROOTS be accidentally set to a string rathe…

…r than a tuple. Thanks to Florian Apolloner for pointing this out.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17571 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3ac0961e1ec3f935474e3c1c3f16bee1cc5ae54a 1 parent a3bb4df
@SmileyChris SmileyChris authored
View
6 django/conf/__init__.py
@@ -73,6 +73,9 @@ def __setattr__(self, name, value):
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 @@ def __init__(self, settings_module):
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)
View
7 tests/regressiontests/settings_tests/tests.py
@@ -150,6 +150,13 @@ def test_settings_delete(self):
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):
View
4 tests/regressiontests/templates/tests.py
@@ -425,7 +425,9 @@ def test_templates(self):
#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.
Please sign in to comment.
Something went wrong with that request. Please try again.