summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Beaven <smileychris@gmail.com>2012-02-22 00:52:19 +0000
committerChris Beaven <smileychris@gmail.com>2012-02-22 00:52:19 +0000
commitb45fbc66670a375b0d6d42ecd160b7c9e9e00dc6 (patch)
treeaf056787985c3ab20eaa887f755afbb48a4141aa
parent0af93e108e3dc5e0216ab45cae2dec86ee750771 (diff)
[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
-rw-r--r--django/conf/__init__.py3
-rw-r--r--tests/regressiontests/settings_tests/tests.py7
-rw-r--r--tests/regressiontests/templates/tests.py4
3 files changed, 13 insertions, 1 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index f2012a6400..3f707b0897 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -70,6 +70,9 @@ class BaseSettings(object):
if name in ("MEDIA_URL", "STATIC_URL") and value and not value.endswith('/'):
warnings.warn('If set, %s must end with a slash' % name,
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)
diff --git a/tests/regressiontests/settings_tests/tests.py b/tests/regressiontests/settings_tests/tests.py
index dc7fde4f2c..37ffd6d577 100644
--- a/tests/regressiontests/settings_tests/tests.py
+++ b/tests/regressiontests/settings_tests/tests.py
@@ -18,6 +18,13 @@ class SettingsTests(unittest.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(unittest.TestCase):
settings_module = settings
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 074852c1c3..d17068821c 100644
--- a/tests/regressiontests/templates/tests.py
+++ b/tests/regressiontests/templates/tests.py
@@ -412,7 +412,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.