Moved fields.py. Fixed template debug unit test failures.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1699 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ecebbb200f
commit
c86bfac264
|
@ -57,7 +57,8 @@ 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, TEMPLATE_DEBUG
|
from django.conf.settings import DEFAULT_CHARSET
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
__all__ = ('Template','Context','compile_string')
|
__all__ = ('Template','Context','compile_string')
|
||||||
|
|
||||||
|
@ -126,7 +127,7 @@ class StringOrigin(Origin):
|
||||||
class Template:
|
class Template:
|
||||||
def __init__(self, template_string, origin=None):
|
def __init__(self, template_string, origin=None):
|
||||||
"Compilation stage"
|
"Compilation stage"
|
||||||
if TEMPLATE_DEBUG and origin == None:
|
if settings.TEMPLATE_DEBUG and origin == None:
|
||||||
origin = StringOrigin(template_string)
|
origin = StringOrigin(template_string)
|
||||||
# Could do some crazy stack-frame stuff to record where this string
|
# Could do some crazy stack-frame stuff to record where this string
|
||||||
# came from...
|
# came from...
|
||||||
|
@ -401,12 +402,19 @@ class DebugParser(Parser):
|
||||||
if not hasattr(e, 'source'):
|
if not hasattr(e, 'source'):
|
||||||
e.source = token.source
|
e.source = token.source
|
||||||
|
|
||||||
if TEMPLATE_DEBUG:
|
|
||||||
lexer_factory = DebugLexer
|
def lexer_factory(*args, **kwargs):
|
||||||
parser_factory = DebugParser
|
if settings.TEMPLATE_DEBUG:
|
||||||
else:
|
return DebugLexer(*args, **kwargs)
|
||||||
lexer_factory = Lexer
|
else:
|
||||||
parser_factory = Parser
|
return Lexer(*args, **kwargs)
|
||||||
|
|
||||||
|
def parser_factory(*args, **kwargs):
|
||||||
|
if settings.TEMPLATE_DEBUG:
|
||||||
|
return DebugParser(*args, **kwargs)
|
||||||
|
else:
|
||||||
|
return Parser(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class TokenParser:
|
class TokenParser:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.template import Origin, StringOrigin, Template, Context, TemplateDoesNotExist, add_to_builtins
|
from django.core.template import Origin, StringOrigin, Template, Context, TemplateDoesNotExist, add_to_builtins
|
||||||
from django.conf.settings import TEMPLATE_LOADERS, TEMPLATE_DEBUG
|
from django.conf.settings import TEMPLATE_LOADERS
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
template_source_loaders = []
|
template_source_loaders = []
|
||||||
for path in TEMPLATE_LOADERS:
|
for path in TEMPLATE_LOADERS:
|
||||||
|
@ -51,7 +52,7 @@ class LoaderOrigin(Origin):
|
||||||
return self.loader(self.loadname, self.dirs)[0]
|
return self.loader(self.loadname, self.dirs)[0]
|
||||||
|
|
||||||
def make_origin(display_name, loader, name, dirs):
|
def make_origin(display_name, loader, name, dirs):
|
||||||
if TEMPLATE_DEBUG:
|
if settings.TEMPLATE_DEBUG:
|
||||||
return LoaderOrigin(display_name, loader, name, dirs)
|
return LoaderOrigin(display_name, loader, name, dirs)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.core.template import TemplateSyntaxError, TemplateDoesNotExist, resolve_variable
|
from django.core.template import TemplateSyntaxError, TemplateDoesNotExist, resolve_variable
|
||||||
from django.core.template import Library, Context, Node
|
from django.core.template import Library, Context, Node
|
||||||
from django.core.template.loader import get_template, get_template_from_string, find_template_source
|
from django.core.template.loader import get_template, get_template_from_string, find_template_source
|
||||||
from django.conf.settings import TEMPLATE_DEBUG
|
|
||||||
register = Library()
|
register = Library()
|
||||||
|
|
||||||
class ExtendsError(Exception):
|
class ExtendsError(Exception):
|
||||||
|
@ -82,6 +82,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 TEMPLATE_DEBUG:
|
if TEMPLATE_DEBUG:
|
||||||
raise
|
raise
|
||||||
self.template = None
|
self.template = None
|
||||||
|
|
|
@ -9,7 +9,7 @@ from django.db.models.query import handle_legacy_orderlist, orderlist2sql, order
|
||||||
GET_ITERATOR_CHUNK_SIZE = 100
|
GET_ITERATOR_CHUNK_SIZE = 100
|
||||||
|
|
||||||
class Manager(object):
|
class Manager(object):
|
||||||
# Tracks each time a Field instance is created. Used to retain order.
|
# Tracks each time a Manager instance is created. Used to retain order.
|
||||||
creation_counter = 0
|
creation_counter = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
# Turn TEMPLATE_DEBUG off, because tests assume that.
|
|
||||||
settings.TEMPLATE_DEBUG = False
|
|
||||||
|
|
||||||
from django.core import template
|
from django.core import template
|
||||||
from django.core.template import loader
|
from django.core.template import loader
|
||||||
|
@ -353,6 +351,9 @@ def run_tests(verbosity=0, standalone=False):
|
||||||
failed_tests = []
|
failed_tests = []
|
||||||
tests = TEMPLATE_TESTS.items()
|
tests = TEMPLATE_TESTS.items()
|
||||||
tests.sort()
|
tests.sort()
|
||||||
|
|
||||||
|
# Turn TEMPLATE_DEBUG off, because tests assume that.
|
||||||
|
old_td, settings.TEMPLATE_DEBUG = settings.TEMPLATE_DEBUG, False
|
||||||
for name, vals in tests:
|
for name, vals in tests:
|
||||||
install()
|
install()
|
||||||
if 'LANGUAGE_CODE' in vals[1]:
|
if 'LANGUAGE_CODE' in vals[1]:
|
||||||
|
@ -382,6 +383,8 @@ def run_tests(verbosity=0, standalone=False):
|
||||||
failed_tests.append(name)
|
failed_tests.append(name)
|
||||||
loader.template_source_loaders = old_template_loaders
|
loader.template_source_loaders = old_template_loaders
|
||||||
deactivate()
|
deactivate()
|
||||||
|
settings.TEMPLATE_DEBUG = old_td
|
||||||
|
|
||||||
if failed_tests and not standalone:
|
if failed_tests and not standalone:
|
||||||
msg = "Template tests %s failed." % failed_tests
|
msg = "Template tests %s failed." % failed_tests
|
||||||
if not verbosity:
|
if not verbosity:
|
||||||
|
|
Loading…
Reference in New Issue