diff --git a/django/core/management.py b/django/core/management.py index 49f447cc74..5e67a6d6b7 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -640,9 +640,9 @@ def runserver(addr, port): sys.exit(1) except KeyboardInterrupt: sys.exit(0) - #from django.utils import autoreload - #autoreload.main(inner_run) - inner_run() + from django.utils import autoreload + autoreload.main(inner_run) + #inner_run() runserver.args = '[optional port number, or ipaddr:port]' def createcachetable(tablename): diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index c0ef8d4de0..16ac1a0e0a 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -1603,6 +1603,7 @@ def manipulator_init(opts, add, change, self, obj_key=None, follow=None): self.fields.append(formfields.CommaSeparatedIntegerField(field_name="order_")) def manipulator_save(opts, klass, add, change, self, new_data): + # TODO: big cleanup when core fields go -> use recursive manipulators. from django.utils.datastructures import DotExpandedDict params = {} for f in opts.fields: diff --git a/django/core/template/__init__.py b/django/core/template/__init__.py index 0a490a0d33..3324d5c6d0 100644 --- a/django/core/template/__init__.py +++ b/django/core/template/__init__.py @@ -224,48 +224,29 @@ class DebugLexer(Lexer): def find_linebreaks(self, template_string): for match in newline_re.finditer(template_string): yield match.start() + yield len(template_string) + 1 def tokenize(self): "Return a list of tokens from a given template_string" - - token_tups = [] - upto = 0 - line = 1 - #TODO:Py2.4 generator expression - linebreaks = self.find_linebreaks(self.template_string) - next_linebreak = linebreaks.next() - - + token_tups, upto = [], 0 + lines = enumerate(self.find_linebreaks(self.template_string)) + line, next_linebreak = lines.next() for match in tag_re.finditer(self.template_string): + while next_linebreak <= upto: + line, next_linebreak = lines.next() start, end = match.span() if start > upto: token_tups.append( (self.template_string[upto:start], line) ) upto = start - while next_linebreak <= upto: - try: - next_linebreak = linebreaks.next() - line += 1 - except StopIteration: - break - + line, next_linebreak = lines.next() token_tups.append( (self.template_string[start:end], line) ) upto = end - - while next_linebreak <= upto: - try: - next_linebreak = linebreaks.next() - line += 1 - except StopIteration: - break - last_bit = self.template_string[upto:] - if len(last_bit): + if last_bit: token_tups.append( (last_bit, line) ) - return [ self.create_token(tok, (self.filename, line)) for tok, line in token_tups] - def create_token(self, token_string, source): token = super(DebugLexer, self).create_token(token_string) token.source = source diff --git a/django/core/template/loader.py b/django/core/template/loader.py index 57db507e9c..8867f916bd 100644 --- a/django/core/template/loader.py +++ b/django/core/template/loader.py @@ -188,7 +188,7 @@ class IncludeNode(Node): try: template_path = resolve_variable(self.template_path_var, context) print "IncludeNode rendering %s" % template_path - t = template_loader.get_template(template_path) + t = get_template(template_path) return t.render(context) except Exception, e: return '' # Fail silently for invalid included templates. diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py index ac0ff13d36..186ac3ce56 100644 --- a/tests/othertests/templates.py +++ b/tests/othertests/templates.py @@ -215,6 +215,24 @@ TEMPLATE_TESTS = { # Raise exception for custom tags used in child with {% load %} tag in parent, not in child 'exception04': ("{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678{% endblock %}", {}, template.TemplateSyntaxError), + + 'multiline01': (""" + Hello, + boys. + How + are + you + gentlemen. + """, + {}, + """ + Hello, + boys. + How + are + you + gentlemen. + """ ), }