exception.py
This file
Path
tests/runtime/exception.py
95 lines · 2.6 KiB · Python
Last changed by
[svn] added groupby filter and fixed some small bugsArmin Ronacherbefore adoptione39a5d2
History of this fileTake it
[svn] fixed supering in jinja, documented it, added lipsum()Armin Ronacherbefore adoption34f3042
lines 1–2why, one step back1import jdebug2import sys[svn] implemented compile time error handlingArmin Ronacherbefore adoption8ff24c4
lines 3–4why, one step back3from jinja import Environment, DictLoader4from jinja.exceptions import TemplateNotFound[svn] moved all jinja tests into a runtime folder so that we have enough space for the new unittestsArmin Ronacherbefore adoptionaa5adfa
lines 5–6why, one step back5from wsgiref.simple_server import make_server6[svn] implemented compile time error handlingArmin Ronacherbefore adoption8ff24c4
lines 7–34why, one step back7e = Environment(loader=DictLoader({8 '/': u'''9<html>10 <head>11 <title>Various Broken Templates</title>12 <style type="text/css">13 body {14 margin: 2em;15 font-size: 1.5em;16 font-family: sans-serif17 }18 a {19 color: #d00;20 }21 </style>22 </head>23 <body>24 <h1>Various Broken Templates</h1>25 <p>26 This small WSGI application serves some Jinja templates that27 are just broken. It uses the colubrid traceback middleware to28 render those errors including source code.29 </p>30 <ul>31 <li><a href="syntax_error">syntax error</a></li>32 <li><a href="runtime_error">runtime error</a></li>33 <li><a href="nested_syntax_error">nested syntax error</a></li>34 <li><a href="nested_runtime_error">nested runtime error</a></li>[svn] added "debugger of awesomeness" :DArmin Ronacherbefore adoptiona7804ef
line 35why, one step back35 <li><a href="code_runtime_error">runtime error in code</a></li>[svn] improved debugging support. it's not possible to catch errors of templates without loaders tooArmin Ronacherbefore adoption10dae5b
lines 36–37why, one step back36 <li><a href="syntax_from_string">a syntax error from string</a></li>37 <li><a href="runtime_from_string">runtime error from a string</a></li>[svn] implemented compile time error handlingArmin Ronacherbefore adoption8ff24c4
lines 38–56why, one step back38 </ul>39 </body>40</html>41''',42 '/syntax_error': u'''43{% for item in foo %}44 ...45{% endif %}46 ''',47 '/runtime_error': u'''48{% set foo = 1 / 0 %}49 ''',50 '/nested_runtime_error': u'''51{% include 'runtime_broken' %}52 ''',53 '/nested_syntax_error': u'''54{% include 'syntax_broken' %}55 ''',56[svn] added groupby filter and fixed some small bugsArmin Ronacherbefore adoptione39a5d2
lines 57–58why, one step back57 '/code_runtime_error': u'''We have a runtime error here:58 {{ broken() }}''',[svn] added "debugger of awesomeness" :DArmin Ronacherbefore adoptiona7804ef
line 59why, one step back59[svn] implemented compile time error handlingArmin Ronacherbefore adoption8ff24c4
lines 60–67why, one step back60 'runtime_broken': '''\61This is an included template62{% set a = 1 / 0 %}''',63 'syntax_broken': '''\64This is an included template65{% raw %}just some foo'''66}))67[svn] improved debugging support. it's not possible to catch errors of templates without loaders tooArmin Ronacherbefore adoption10dae5b
lines 68–69why, one step back68FAILING_STRING_TEMPLATE = '{{ 1 / 0 }}'69BROKEN_STRING_TEMPLATE = '{% if foo %}...{% endfor %}'[svn] implemented compile time error handlingArmin Ronacherbefore adoption8ff24c4
line 70why, one step back70[svn] improved debugging support. it's not possible to catch errors of templates without loaders tooArmin Ronacherbefore adoption10dae5b
line 71why, one step back71[svn] added "debugger of awesomeness" :DArmin Ronacherbefore adoptiona7804ef
lines 72–75why, one step back72def broken():73 raise RuntimeError("I'm broken")7475[svn] implemented compile time error handlingArmin Ronacherbefore adoption8ff24c4
line 76why, one step back76def test(environ, start_response):[svn] improved debugging support. it's not possible to catch errors of templates without loaders tooArmin Ronacherbefore adoption10dae5b
line 77why, one step back77 path = environ.get('PATH_INFO' or '/')[svn] implemented compile time error handlingArmin Ronacherbefore adoption8ff24c4
line 78why, one step back78 try:[svn] improved debugging support. it's not possible to catch errors of templates without loaders tooArmin Ronacherbefore adoption10dae5b
line 79why, one step back79 tmpl = e.get_template(path)[svn] implemented compile time error handlingArmin Ronacherbefore adoption8ff24c4
line 80why, one step back80 except TemplateNotFound:[svn] improved debugging support. it's not possible to catch errors of templates without loaders tooArmin Ronacherbefore adoption10dae5b
lines 81–87why, one step back81 if path == '/syntax_from_string':82 tmpl = e.from_string(BROKEN_STRING_TEMPLATE)83 elif path == '/runtime_from_string':84 tmpl = e.from_string(FAILING_STRING_TEMPLATE)85 else:86 start_response('404 NOT FOUND', [('Content-Type', 'text/plain')])87 return ['NOT FOUND'][svn] implemented compile time error handlingArmin Ronacherbefore adoption8ff24c4
line 88why, one step back88 start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])[svn] added "debugger of awesomeness" :DArmin Ronacherbefore adoptiona7804ef
line 89why, one step back89 return [tmpl.render(broken=broken).encode('utf-8')][svn] moved all jinja tests into a runtime folder so that we have enough space for the new unittestsArmin Ronacherbefore adoptionaa5adfa
line 90why, one step back90[svn] added "debugger of awesomeness" :DArmin Ronacherbefore adoptiona7804ef
line 91why, one step back91[svn] fixed supering in jinja, documented it, added lipsum()Armin Ronacherbefore adoption34f3042
line 92why, one step back92if __name__ == '__main__':[svn] added "debugger of awesomeness" :DArmin Ronacherbefore adoptiona7804ef
line 93why, one step back93 from werkzeug.debug import DebuggedApplication[svn] fixed supering in jinja, documented it, added lipsum()Armin Ronacherbefore adoption34f3042
lines 94–95why, one step back94 app = DebuggedApplication(test)95 make_server("localhost", 7000, app).serve_forever()