mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
[1.3.X] Don't let ALLOWED_INCLUDE_ROOTS be accidentally set to a string rather than a tuple.
Backport of r17571 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@17572 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0af93e108e
commit
b45fbc6667
@ -70,6 +70,9 @@ class BaseSettings(object):
|
|||||||
if name in ("MEDIA_URL", "STATIC_URL") and value and not value.endswith('/'):
|
if name in ("MEDIA_URL", "STATIC_URL") and value and not value.endswith('/'):
|
||||||
warnings.warn('If set, %s must end with a slash' % name,
|
warnings.warn('If set, %s must end with a slash' % name,
|
||||||
PendingDeprecationWarning)
|
PendingDeprecationWarning)
|
||||||
|
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)
|
object.__setattr__(self, name, value)
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,13 @@ class SettingsTests(unittest.TestCase):
|
|||||||
def test_settings_delete_wrapped(self):
|
def test_settings_delete_wrapped(self):
|
||||||
self.assertRaises(TypeError, delattr, settings, '_wrapped')
|
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(unittest.TestCase):
|
class TrailingSlashURLTests(unittest.TestCase):
|
||||||
settings_module = settings
|
settings_module = settings
|
||||||
|
@ -412,7 +412,9 @@ class Templates(unittest.TestCase):
|
|||||||
|
|
||||||
#Set ALLOWED_INCLUDE_ROOTS so that ssi works.
|
#Set ALLOWED_INCLUDE_ROOTS so that ssi works.
|
||||||
old_allowed_include_roots = settings.ALLOWED_INCLUDE_ROOTS
|
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
|
# Warm the URL reversing cache. This ensures we don't pay the cost
|
||||||
# warming the cache during one of the tests.
|
# warming the cache during one of the tests.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user