Permalink
Browse files

Fixed #12248 -- Refactored django.template to get code out of __init_…

…_.py, to help with avoiding circular import dependencies. Thanks to Tom Tobin for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14722 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 5fc9cbc commit 0be14b0b9647b1662c41e7e408072ebe19f28929 @freakboy3742 freakboy3742 committed Nov 27, 2010
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,5 +1,5 @@
from django.conf import settings
-from django.template import Lexer, Parser, tag_re, NodeList, VariableNode, TemplateSyntaxError
+from django.template.base import Lexer, Parser, tag_re, NodeList, VariableNode, TemplateSyntaxError
from django.utils.encoding import force_unicode
from django.utils.html import escape
from django.utils.safestring import SafeData, EscapeData
@@ -8,7 +8,7 @@
except ImportError:
from django.utils.functional import wraps # Python 2.4 fallback.
-from django.template import Variable, Library
+from django.template.base import Variable, Library
from django.conf import settings
from django.utils import formats
from django.utils.encoding import force_unicode, iri_to_uri
@@ -4,9 +4,9 @@
import re
from itertools import groupby, cycle as itertools_cycle
-from django.template import Node, NodeList, Template, Context, Variable
-from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END
-from django.template import get_library, Library, InvalidTemplateLibrary
+from django.template.base import Node, NodeList, Template, Context, Variable
+from django.template.base import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END
+from django.template.base import get_library, Library, InvalidTemplateLibrary
from django.template.smartif import IfParser, Literal
from django.conf import settings
from django.utils.encoding import smart_str, smart_unicode
@@ -26,7 +26,7 @@
# installed, because pkg_resources is necessary to read eggs.
from django.core.exceptions import ImproperlyConfigured
-from django.template import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins
+from django.template.base import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins
from django.utils.importlib import import_module
from django.conf import settings
@@ -1,5 +1,5 @@
-from django.template import TemplateSyntaxError, TemplateDoesNotExist, Variable
-from django.template import Library, Node, TextNode
+from django.template.base import TemplateSyntaxError, TemplateDoesNotExist, Variable
+from django.template.base import Library, Node, TextNode
from django.template.loader import get_template
from django.conf import settings
from django.utils.safestring import mark_safe
@@ -8,7 +8,7 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
-from django.template import TemplateDoesNotExist
+from django.template.base import TemplateDoesNotExist
from django.template.loader import BaseLoader
from django.utils._os import safe_join
from django.utils.importlib import import_module
@@ -4,7 +4,7 @@
"""
from django.core.exceptions import ImproperlyConfigured
-from django.template import TemplateDoesNotExist
+from django.template.base import TemplateDoesNotExist
from django.template.loader import BaseLoader, get_template_from_string, find_template_loader, make_origin
from django.utils.hashcompat import sha_constructor
from django.utils.importlib import import_module
@@ -5,7 +5,7 @@
except ImportError:
resource_string = None
-from django.template import TemplateDoesNotExist
+from django.template.base import TemplateDoesNotExist
from django.template.loader import BaseLoader
from django.conf import settings
@@ -3,7 +3,7 @@
"""
from django.conf import settings
-from django.template import TemplateDoesNotExist
+from django.template.base import TemplateDoesNotExist
from django.template.loader import BaseLoader
from django.utils._os import safe_join
@@ -1,8 +1,9 @@
import re
-from django.template import Node, Variable, VariableNode, _render_value_in_context
+from django.template import Node, Variable, VariableNode
from django.template import TemplateSyntaxError, TokenParser, Library
from django.template import TOKEN_TEXT, TOKEN_VAR
+from django.template.base import _render_value_in_context
from django.utils import translation
from django.utils.encoding import force_unicode
@@ -13,6 +13,7 @@
import traceback
from django import template
+from django.template import base as template_base
from django.core import urlresolvers
from django.template import loader
from django.template.loaders import app_directories, filesystem, cached
@@ -375,7 +376,7 @@ def test_template_loader(template_name, template_dirs=None):
if isinstance(invalid_string_result, basestring) and '%s' in invalid_string_result:
expected_invalid_str = 'INVALID %s'
invalid_string_result = invalid_string_result % vals[2][2]
- template.invalid_var_format_string = True
+ template_base.invalid_var_format_string = True
else:
normal_string_result = vals[2]
invalid_string_result = vals[2]
@@ -417,9 +418,9 @@ def test_template_loader(template_name, template_dirs=None):
if 'LANGUAGE_CODE' in vals[1]:
deactivate()
- if template.invalid_var_format_string:
+ if template_base.invalid_var_format_string:
expected_invalid_str = 'INVALID'
- template.invalid_var_format_string = False
+ template_base.invalid_var_format_string = False
loader.template_source_loaders = old_template_loaders
deactivate()
@@ -1463,13 +1464,13 @@ def setUp(self):
self.old_path = sys.path[:]
self.old_apps = settings.INSTALLED_APPS
self.egg_dir = '%s/eggs' % os.path.dirname(__file__)
- self.old_tag_modules = template.templatetags_modules
- template.templatetags_modules = []
+ self.old_tag_modules = template_base.templatetags_modules
+ template_base.templatetags_modules = []
def tearDown(self):
settings.INSTALLED_APPS = self.old_apps
sys.path = self.old_path
- template.templatetags_modules = self.old_tag_modules
+ template_base.templatetags_modules = self.old_tag_modules
def test_load_error(self):
ttext = "{% load broken_tag %}"

0 comments on commit 0be14b0

Please sign in to comment.