Don't let ALLOWED_INCLUDE_ROOTS be accidentally set to a string rather 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
This commit is contained in:
parent
a3bb4df895
commit
3ac0961e1e
|
@ -73,6 +73,9 @@ class BaseSettings(object):
|
|||
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 @@ class Settings(BaseSettings):
|
|||
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)
|
||||
|
||||
|
|
|
@ -150,6 +150,13 @@ class SettingsTests(TestCase):
|
|||
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):
|
||||
|
|
|
@ -425,7 +425,9 @@ class Templates(unittest.TestCase):
|
|||
|
||||
#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.
|
||||
|
|
Loading…
Reference in New Issue