Skip to content
Myr

[svn] readded debug function

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 22e1162 · Browse files · 5 files+16 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+16 added−4 removed

  • tests:+3 added−2 removed
  • other:+13 added−2 removed

5 files+16 added−4 removed

modified:jinja/translators/python.py-1 removed
300 unmodified lines
301 lines.append(self.handle_node(n))302303 # the template body304 body_lines = [self.handle_node(n) for n in node]305 print list(node)305306 # add translation helpers if required307 if self.require_translations:308 lines.append(
553 unmodified lines
modified:jinja/defaults.py+3 added-1 removed
8 unmodified lines
9 :license: BSD, see LICENSE for more details.10"""11from jinja.filters import FILTERS as DEFAULT_FILTERS12from jinja.tests import TESTS as DEFAULT_TESTS13from jinja.utils import debug_context141516DEFAULT_NAMESPACE = {16 'range': range17 'range': range,18 'debug': debug_context19}
modified:jinja/utils.py+10 added
54 unmodified lines
55 yield node.lineno, node.singular, node.plural56 queue.extend(node.getChildNodes())575859def debug_context():60 """61 Use this function in templates to get a printed context.62 Use this only in templates because it touches the stack.63 """64 context = sys._getframe(2).f_locals['context']65 from pprint import pformat66 return pformat(context.to_dict())676869# python2.4 and lower has a bug regarding joining of broken generators70if sys.hexversion < (2, 5):71 def capture_generator(gen):72 """
210 unmodified lines
modified:tests/templates/error.html+2 added-1 removed
modified:tests/exception.py+1 added-1 removed
5 unmodified lines
6def test(*args):7 tmpl = e.loader.load('error.html')8 tmpl.render(items=range(10))910make_server("localhost", 7000, DebuggedApplication(test)).serve_forever()10make_server("localhost", 7000, DebuggedApplication(test, False)).serve_forever()