mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +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:
parent
27d4bb9460
commit
692d1332f9
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
""" ),
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user