1
0
mirror of https://github.com/django/django.git synced 2025-07-05 10:19:20 +00:00

Cleanups of old debug bits. Fully clean DebugLexer.

Reverted some testing changes. 



git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@906 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Robert Wittams 2005-10-17 14:26:41 +00:00
parent 27d4bb9460
commit 692d1332f9
5 changed files with 31 additions and 31 deletions

View File

@ -640,9 +640,9 @@ def runserver(addr, port):
sys.exit(1) sys.exit(1)
except KeyboardInterrupt: except KeyboardInterrupt:
sys.exit(0) sys.exit(0)
#from django.utils import autoreload from django.utils import autoreload
#autoreload.main(inner_run) autoreload.main(inner_run)
inner_run() #inner_run()
runserver.args = '[optional port number, or ipaddr:port]' runserver.args = '[optional port number, or ipaddr:port]'
def createcachetable(tablename): def createcachetable(tablename):

View File

@ -1603,6 +1603,7 @@ def manipulator_init(opts, add, change, self, obj_key=None, follow=None):
self.fields.append(formfields.CommaSeparatedIntegerField(field_name="order_")) self.fields.append(formfields.CommaSeparatedIntegerField(field_name="order_"))
def manipulator_save(opts, klass, add, change, self, new_data): 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 from django.utils.datastructures import DotExpandedDict
params = {} params = {}
for f in opts.fields: for f in opts.fields:

View File

@ -224,48 +224,29 @@ class DebugLexer(Lexer):
def find_linebreaks(self, template_string): def find_linebreaks(self, template_string):
for match in newline_re.finditer(template_string): for match in newline_re.finditer(template_string):
yield match.start() yield match.start()
yield len(template_string) + 1
def tokenize(self): def tokenize(self):
"Return a list of tokens from a given template_string" "Return a list of tokens from a given template_string"
token_tups, upto = [], 0
token_tups = [] lines = enumerate(self.find_linebreaks(self.template_string))
upto = 0 line, next_linebreak = lines.next()
line = 1
#TODO:Py2.4 generator expression
linebreaks = self.find_linebreaks(self.template_string)
next_linebreak = linebreaks.next()
for match in tag_re.finditer(self.template_string): for match in tag_re.finditer(self.template_string):
while next_linebreak <= upto:
line, next_linebreak = lines.next()
start, end = match.span() start, end = match.span()
if start > upto: if start > upto:
token_tups.append( (self.template_string[upto:start], line) ) token_tups.append( (self.template_string[upto:start], line) )
upto = start upto = start
while next_linebreak <= upto: while next_linebreak <= upto:
try: line, next_linebreak = lines.next()
next_linebreak = linebreaks.next()
line += 1
except StopIteration:
break
token_tups.append( (self.template_string[start:end], line) ) token_tups.append( (self.template_string[start:end], line) )
upto = end upto = end
while next_linebreak <= upto:
try:
next_linebreak = linebreaks.next()
line += 1
except StopIteration:
break
last_bit = self.template_string[upto:] last_bit = self.template_string[upto:]
if len(last_bit): if last_bit:
token_tups.append( (last_bit, line) ) token_tups.append( (last_bit, line) )
return [ self.create_token(tok, (self.filename, line)) for tok, line in token_tups] return [ self.create_token(tok, (self.filename, line)) for tok, line in token_tups]
def create_token(self, token_string, source): def create_token(self, token_string, source):
token = super(DebugLexer, self).create_token(token_string) token = super(DebugLexer, self).create_token(token_string)
token.source = source token.source = source

View File

@ -188,7 +188,7 @@ class IncludeNode(Node):
try: try:
template_path = resolve_variable(self.template_path_var, context) template_path = resolve_variable(self.template_path_var, context)
print "IncludeNode rendering %s" % template_path print "IncludeNode rendering %s" % template_path
t = template_loader.get_template(template_path) t = get_template(template_path)
return t.render(context) return t.render(context)
except Exception, e: except Exception, e:
return '' # Fail silently for invalid included templates. return '' # Fail silently for invalid included templates.

View File

@ -215,6 +215,24 @@ TEMPLATE_TESTS = {
# Raise exception for custom tags used in child with {% load %} tag in parent, not in child # 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), 'exception04': ("{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678{% endblock %}", {}, template.TemplateSyntaxError),
'multiline01': ("""
Hello,
boys.
How
are
you
gentlemen.
""",
{},
"""
Hello,
boys.
How
are
you
gentlemen.
""" ),
} }