diff --git a/django/template/__init__.py b/django/template/__init__.py index d87653c21c..4f06f34e6b 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -57,7 +57,7 @@ times with multiple contexts) import re from inspect import getargspec from django.utils.functional import curry -from django.conf.settings import DEFAULT_CHARSET +from django.conf import settings from django.conf import settings from django.template.context import Context, RequestContext @@ -714,7 +714,7 @@ class VariableNode(Node): if not isinstance(output, basestring): return str(output) elif isinstance(output, unicode): - return output.encode(DEFAULT_CHARSET) + return output.encode(settings.DEFAULT_CHARSET) else: return output diff --git a/django/template/context.py b/django/template/context.py index 1b91d8eb34..2571f35255 100644 --- a/django/template/context.py +++ b/django/template/context.py @@ -1,4 +1,4 @@ -from django.conf.settings import TEMPLATE_CONTEXT_PROCESSORS +from django.conf import settings from django.core.exceptions import ImproperlyConfigured _standard_context_processors = None @@ -61,7 +61,7 @@ def get_standard_processors(): global _standard_context_processors if _standard_context_processors is None: processors = [] - for path in TEMPLATE_CONTEXT_PROCESSORS: + for path in settings.TEMPLATE_CONTEXT_PROCESSORS: i = path.rfind('.') module, attr = path[:i], path[i+1:] try: diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index 34fffcb8a1..fa4975e643 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -1,7 +1,7 @@ "Default variable filters" from django.template import resolve_variable, Library -from django.conf.settings import DATE_FORMAT, TIME_FORMAT +from django.conf import settings from django.utils.translation import gettext import re import random as random_module @@ -327,12 +327,12 @@ def get_digit(value, arg): # DATES # ################### -def date(value, arg=DATE_FORMAT): +def date(value, arg=settings.DATE_FORMAT): "Formats a date according to the given format" from django.utils.dateformat import format return format(value, arg) -def time(value, arg=TIME_FORMAT): +def time(value, arg=settings.TIME_FORMAT): "Formats a time according to the given format" from django.utils.dateformat import time_format return time_format(value, arg) diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index a460c34e85..2d8cdd6d26 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -3,6 +3,7 @@ from django.template import Node, NodeList, Template, Context, resolve_variable from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END from django.template import get_library, Library, InvalidTemplateLibrary +from django.conf import settings import sys register = Library() @@ -201,8 +202,7 @@ class RegroupNode(Node): return '' def include_is_allowed(filepath): - from django.conf.settings import ALLOWED_INCLUDE_ROOTS - for root in ALLOWED_INCLUDE_ROOTS: + for root in settings.ALLOWED_INCLUDE_ROOTS: if filepath.startswith(root): return True return False @@ -212,9 +212,8 @@ class SsiNode(Node): self.filepath, self.parsed = filepath, parsed def render(self, context): - from django.conf.settings import DEBUG if not include_is_allowed(self.filepath): - if DEBUG: + if settings.DEBUG: return "[Didn't have permission to include file]" else: return '' # Fail silently for invalid includes. @@ -229,7 +228,7 @@ class SsiNode(Node): t = Template(output) return t.render(context) except TemplateSyntaxError, e: - if DEBUG: + if settings.DEBUG: return "[Included template had syntax error: %s]" % e else: return '' # Fail silently for invalid included templates. diff --git a/django/template/loader.py b/django/template/loader.py index 1172410557..631b3f255c 100644 --- a/django/template/loader.py +++ b/django/template/loader.py @@ -22,11 +22,11 @@ from django.core.exceptions import ImproperlyConfigured from django.template import Origin, StringOrigin, Template, Context, TemplateDoesNotExist, add_to_builtins -from django.conf.settings import TEMPLATE_LOADERS +from django.conf import settings from django.conf import settings template_source_loaders = [] -for path in TEMPLATE_LOADERS: +for path in settings.TEMPLATE_LOADERS: i = path.rfind('.') module, attr = path[:i], path[i+1:] try: diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py index eafe902b82..5aaef668c8 100644 --- a/django/template/loader_tags.py +++ b/django/template/loader_tags.py @@ -1,6 +1,7 @@ from django.template import TemplateSyntaxError, TemplateDoesNotExist, resolve_variable from django.template import Library, Context, Node from django.template.loader import get_template, get_template_from_string, find_template_source +from django.conf import settings register = Library() @@ -82,8 +83,7 @@ class ConstantIncludeNode(Node): t = get_template(template_path) self.template = t except: - from django.conf.settings import TEMPLATE_DEBUG - if TEMPLATE_DEBUG: + if settings.TEMPLATE_DEBUG: raise self.template = None @@ -103,7 +103,7 @@ class IncludeNode(Node): t = get_template(template_name) return t.render(context) except TemplateSyntaxError, e: - if TEMPLATE_DEBUG: + if settings.TEMPLATE_DEBUG: raise return '' except: diff --git a/django/template/loaders/app_directories.py b/django/template/loaders/app_directories.py index 1d4dc6bef7..46b736d464 100644 --- a/django/template/loaders/app_directories.py +++ b/django/template/loaders/app_directories.py @@ -1,13 +1,13 @@ # Wrapper for loading templates from "template" directories in installed app packages. -from django.conf.settings import INSTALLED_APPS, TEMPLATE_FILE_EXTENSION +from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.template import TemplateDoesNotExist import os # At compile time, cache the directories to search. app_template_dirs = [] -for app in INSTALLED_APPS: +for app in settings.INSTALLED_APPS: i = app.rfind('.') if i == -1: m, a = app, None @@ -29,7 +29,7 @@ app_template_dirs = tuple(app_template_dirs) def get_template_sources(template_name, template_dirs=None): for template_dir in app_template_dirs: - yield os.path.join(template_dir, template_name) + TEMPLATE_FILE_EXTENSION + yield os.path.join(template_dir, template_name) + settings.TEMPLATE_FILE_EXTENSION def load_template_source(template_name, template_dirs=None): for filepath in get_template_sources(template_name, template_dirs): diff --git a/django/template/loaders/eggs.py b/django/template/loaders/eggs.py index 62e4d4db33..2e47c985ad 100644 --- a/django/template/loaders/eggs.py +++ b/django/template/loaders/eggs.py @@ -6,7 +6,7 @@ except ImportError: resource_string = None from django.template import TemplateDoesNotExist -from django.conf.settings import INSTALLED_APPS, TEMPLATE_FILE_EXTENSION +from django.conf import settings def load_template_source(template_name, template_dirs=None): """ @@ -15,8 +15,8 @@ def load_template_source(template_name, template_dirs=None): For every installed app, it tries to get the resource (app, template_name). """ if resource_string is not None: - pkg_name = 'templates/' + template_name + TEMPLATE_FILE_EXTENSION - for app in INSTALLED_APPS: + pkg_name = 'templates/' + template_name + settings.TEMPLATE_FILE_EXTENSION + for app in settings.INSTALLED_APPS: try: return (resource_string(app, pkg_name), 'egg:%s:%s ' % (app, pkg_name)) except: diff --git a/django/template/loaders/filesystem.py b/django/template/loaders/filesystem.py index 4abe50d764..ee34c6c715 100644 --- a/django/template/loaders/filesystem.py +++ b/django/template/loaders/filesystem.py @@ -1,14 +1,14 @@ # Wrapper for loading templates from the filesystem. -from django.conf.settings import TEMPLATE_DIRS, TEMPLATE_FILE_EXTENSION +from django.conf import settings from django.template import TemplateDoesNotExist import os def get_template_sources(template_name, template_dirs=None): if not template_dirs: - template_dirs = TEMPLATE_DIRS + template_dirs = settings.TEMPLATE_DIRS for template_dir in template_dirs: - yield os.path.join(template_dir, template_name) + TEMPLATE_FILE_EXTENSION + yield os.path.join(template_dir, template_name) + settings.TEMPLATE_FILE_EXTENSION def load_template_source(template_name, template_dirs=None): tried = []