mirror of
https://github.com/django/django.git
synced 2025-04-20 15:24:35 +00:00
magic-removal: changed explicit settings import to qualified settings import - last part, this is all in django.template
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2008 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
41e36aba95
commit
2221cdabff
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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 = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user