mirror of
https://github.com/django/django.git
synced 2025-06-07 12:39:12 +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
|
import re
|
||||||
from inspect import getargspec
|
from inspect import getargspec
|
||||||
from django.utils.functional import curry
|
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.conf import settings
|
||||||
from django.template.context import Context, RequestContext
|
from django.template.context import Context, RequestContext
|
||||||
|
|
||||||
@ -714,7 +714,7 @@ class VariableNode(Node):
|
|||||||
if not isinstance(output, basestring):
|
if not isinstance(output, basestring):
|
||||||
return str(output)
|
return str(output)
|
||||||
elif isinstance(output, unicode):
|
elif isinstance(output, unicode):
|
||||||
return output.encode(DEFAULT_CHARSET)
|
return output.encode(settings.DEFAULT_CHARSET)
|
||||||
else:
|
else:
|
||||||
return output
|
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
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
|
||||||
_standard_context_processors = None
|
_standard_context_processors = None
|
||||||
@ -61,7 +61,7 @@ def get_standard_processors():
|
|||||||
global _standard_context_processors
|
global _standard_context_processors
|
||||||
if _standard_context_processors is None:
|
if _standard_context_processors is None:
|
||||||
processors = []
|
processors = []
|
||||||
for path in TEMPLATE_CONTEXT_PROCESSORS:
|
for path in settings.TEMPLATE_CONTEXT_PROCESSORS:
|
||||||
i = path.rfind('.')
|
i = path.rfind('.')
|
||||||
module, attr = path[:i], path[i+1:]
|
module, attr = path[:i], path[i+1:]
|
||||||
try:
|
try:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"Default variable filters"
|
"Default variable filters"
|
||||||
|
|
||||||
from django.template import resolve_variable, Library
|
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
|
from django.utils.translation import gettext
|
||||||
import re
|
import re
|
||||||
import random as random_module
|
import random as random_module
|
||||||
@ -327,12 +327,12 @@ def get_digit(value, arg):
|
|||||||
# DATES #
|
# DATES #
|
||||||
###################
|
###################
|
||||||
|
|
||||||
def date(value, arg=DATE_FORMAT):
|
def date(value, arg=settings.DATE_FORMAT):
|
||||||
"Formats a date according to the given format"
|
"Formats a date according to the given format"
|
||||||
from django.utils.dateformat import format
|
from django.utils.dateformat import format
|
||||||
return format(value, arg)
|
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"
|
"Formats a time according to the given format"
|
||||||
from django.utils.dateformat import time_format
|
from django.utils.dateformat import time_format
|
||||||
return time_format(value, arg)
|
return time_format(value, arg)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from django.template import Node, NodeList, Template, Context, resolve_variable
|
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 TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END
|
||||||
from django.template import get_library, Library, InvalidTemplateLibrary
|
from django.template import get_library, Library, InvalidTemplateLibrary
|
||||||
|
from django.conf import settings
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
register = Library()
|
register = Library()
|
||||||
@ -201,8 +202,7 @@ class RegroupNode(Node):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
def include_is_allowed(filepath):
|
def include_is_allowed(filepath):
|
||||||
from django.conf.settings import ALLOWED_INCLUDE_ROOTS
|
for root in settings.ALLOWED_INCLUDE_ROOTS:
|
||||||
for root in ALLOWED_INCLUDE_ROOTS:
|
|
||||||
if filepath.startswith(root):
|
if filepath.startswith(root):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -212,9 +212,8 @@ class SsiNode(Node):
|
|||||||
self.filepath, self.parsed = filepath, parsed
|
self.filepath, self.parsed = filepath, parsed
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
from django.conf.settings import DEBUG
|
|
||||||
if not include_is_allowed(self.filepath):
|
if not include_is_allowed(self.filepath):
|
||||||
if DEBUG:
|
if settings.DEBUG:
|
||||||
return "[Didn't have permission to include file]"
|
return "[Didn't have permission to include file]"
|
||||||
else:
|
else:
|
||||||
return '' # Fail silently for invalid includes.
|
return '' # Fail silently for invalid includes.
|
||||||
@ -229,7 +228,7 @@ class SsiNode(Node):
|
|||||||
t = Template(output)
|
t = Template(output)
|
||||||
return t.render(context)
|
return t.render(context)
|
||||||
except TemplateSyntaxError, e:
|
except TemplateSyntaxError, e:
|
||||||
if DEBUG:
|
if settings.DEBUG:
|
||||||
return "[Included template had syntax error: %s]" % e
|
return "[Included template had syntax error: %s]" % e
|
||||||
else:
|
else:
|
||||||
return '' # Fail silently for invalid included templates.
|
return '' # Fail silently for invalid included templates.
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.template import Origin, StringOrigin, Template, Context, TemplateDoesNotExist, add_to_builtins
|
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
|
from django.conf import settings
|
||||||
|
|
||||||
template_source_loaders = []
|
template_source_loaders = []
|
||||||
for path in TEMPLATE_LOADERS:
|
for path in settings.TEMPLATE_LOADERS:
|
||||||
i = path.rfind('.')
|
i = path.rfind('.')
|
||||||
module, attr = path[:i], path[i+1:]
|
module, attr = path[:i], path[i+1:]
|
||||||
try:
|
try:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from django.template import TemplateSyntaxError, TemplateDoesNotExist, resolve_variable
|
from django.template import TemplateSyntaxError, TemplateDoesNotExist, resolve_variable
|
||||||
from django.template import Library, Context, Node
|
from django.template import Library, Context, Node
|
||||||
from django.template.loader import get_template, get_template_from_string, find_template_source
|
from django.template.loader import get_template, get_template_from_string, find_template_source
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
register = Library()
|
register = Library()
|
||||||
|
|
||||||
@ -82,8 +83,7 @@ class ConstantIncludeNode(Node):
|
|||||||
t = get_template(template_path)
|
t = get_template(template_path)
|
||||||
self.template = t
|
self.template = t
|
||||||
except:
|
except:
|
||||||
from django.conf.settings import TEMPLATE_DEBUG
|
if settings.TEMPLATE_DEBUG:
|
||||||
if TEMPLATE_DEBUG:
|
|
||||||
raise
|
raise
|
||||||
self.template = None
|
self.template = None
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class IncludeNode(Node):
|
|||||||
t = get_template(template_name)
|
t = get_template(template_name)
|
||||||
return t.render(context)
|
return t.render(context)
|
||||||
except TemplateSyntaxError, e:
|
except TemplateSyntaxError, e:
|
||||||
if TEMPLATE_DEBUG:
|
if settings.TEMPLATE_DEBUG:
|
||||||
raise
|
raise
|
||||||
return ''
|
return ''
|
||||||
except:
|
except:
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
# Wrapper for loading templates from "template" directories in installed app packages.
|
# 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.core.exceptions import ImproperlyConfigured
|
||||||
from django.template import TemplateDoesNotExist
|
from django.template import TemplateDoesNotExist
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# At compile time, cache the directories to search.
|
# At compile time, cache the directories to search.
|
||||||
app_template_dirs = []
|
app_template_dirs = []
|
||||||
for app in INSTALLED_APPS:
|
for app in settings.INSTALLED_APPS:
|
||||||
i = app.rfind('.')
|
i = app.rfind('.')
|
||||||
if i == -1:
|
if i == -1:
|
||||||
m, a = app, None
|
m, a = app, None
|
||||||
@ -29,7 +29,7 @@ app_template_dirs = tuple(app_template_dirs)
|
|||||||
|
|
||||||
def get_template_sources(template_name, template_dirs=None):
|
def get_template_sources(template_name, template_dirs=None):
|
||||||
for template_dir in app_template_dirs:
|
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):
|
def load_template_source(template_name, template_dirs=None):
|
||||||
for filepath in get_template_sources(template_name, template_dirs):
|
for filepath in get_template_sources(template_name, template_dirs):
|
||||||
|
@ -6,7 +6,7 @@ except ImportError:
|
|||||||
resource_string = None
|
resource_string = None
|
||||||
|
|
||||||
from django.template import TemplateDoesNotExist
|
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):
|
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).
|
For every installed app, it tries to get the resource (app, template_name).
|
||||||
"""
|
"""
|
||||||
if resource_string is not None:
|
if resource_string is not None:
|
||||||
pkg_name = 'templates/' + template_name + TEMPLATE_FILE_EXTENSION
|
pkg_name = 'templates/' + template_name + settings.TEMPLATE_FILE_EXTENSION
|
||||||
for app in INSTALLED_APPS:
|
for app in settings.INSTALLED_APPS:
|
||||||
try:
|
try:
|
||||||
return (resource_string(app, pkg_name), 'egg:%s:%s ' % (app, pkg_name))
|
return (resource_string(app, pkg_name), 'egg:%s:%s ' % (app, pkg_name))
|
||||||
except:
|
except:
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# Wrapper for loading templates from the filesystem.
|
# 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
|
from django.template import TemplateDoesNotExist
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def get_template_sources(template_name, template_dirs=None):
|
def get_template_sources(template_name, template_dirs=None):
|
||||||
if not template_dirs:
|
if not template_dirs:
|
||||||
template_dirs = TEMPLATE_DIRS
|
template_dirs = settings.TEMPLATE_DIRS
|
||||||
for template_dir in 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):
|
def load_template_source(template_name, template_dirs=None):
|
||||||
tried = []
|
tried = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user