Exemple #1
0
 def exec_input(self, tbid, debug_info, input, **kw):
     if not input.strip():
         return ''
     input = input.rstrip() + '\n'
     frame = debug_info.frame(int(tbid))
     vars = frame.tb_frame.f_locals
     glob_vars = frame.tb_frame.f_globals
     context = evalcontext.EvalContext(vars, glob_vars)
     registry.restorer.restoration_begin(debug_info.counter)
     output = context.exec_expr(input)
     registry.restorer.restoration_end()
     input_html = formatter.str2html(input)
     return ('<code style="color: #060">&gt;&gt;&gt;</code> '
             '<code>%s</code><br>\n%s' % (preserve_whitespace(
                 input_html, quote=False), preserve_whitespace(output)))
Exemple #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