Пример #1
0
 def exec_input(self, req):
     input = req.params.get('input')
     if not input.strip():
         return ''
     input = input.rstrip() + '\n'
     frame = req.debug_info.frame(int(req.params['tbid']))
     vars = frame.tb_frame.f_locals
     glob_vars = frame.tb_frame.f_globals
     context = evalcontext.EvalContext(vars, glob_vars)
     registry.restorer.restoration_begin(req.debug_info.counter)
     try:
         output = context.exec_expr(input)
     finally:
         registry.restorer.restoration_end()
     input_html = formatter.str2html(input)
     res = Response(content_type='text/html')
     res.write('<code style="color: #060">&gt;&gt;&gt;</code> '
               '%s<br>\n%s' % (preserve_whitespace(
                   input_html, quote=False), preserve_whitespace(output)))
     return res
Пример #2
0
 def exec_input(self, req):
     input = req.params.get("input")
     if not input.strip():
         return ""
     input = input.rstrip() + "\n"
     frame = req.debug_info.frame(int(req.params["tbid"]))
     vars = frame.tb_frame.f_locals
     glob_vars = frame.tb_frame.f_globals
     context = evalcontext.EvalContext(vars, glob_vars)
     registry.restorer.restoration_begin(req.debug_info.counter)
     try:
         output = context.exec_expr(input)
     finally:
         registry.restorer.restoration_end()
     input_html = formatter.str2html(input)
     res = Response(content_type="text/html")
     res.write(
         '<code style="color: #060">&gt;&gt;&gt;</code> '
         "%s<br>\n%s" % (preserve_whitespace(input_html, quote=False), preserve_whitespace(output))
     )
     return res