Пример #1
0
    def __call__(self):

        if self.request.method != "POST":
            raise Unauthorized()

        line = self.request.form.get("line", "")
        if not line.strip():
            return ""

        line = line.rstrip() + "\n"

        portal = getToolByName(self.context, "portal_url").getPortalObject()
        app = portal.getPhysicalRoot()

        globs = {"context": self.context, "request": self.request, "portal": portal, "app": app}

        globs.update(VARS.get(self.context))
        context = evalcontext.EvalContext({}, globs)
        output = context.exec_expr(line)
        VARS.update(self.context, globs)

        line_html = formatter.str2html(line)
        return '<code style="color: #060">&gt;&gt;&gt;</code> ' "%s<br />\n%s" % (
            preserveWhitespace(line_html, quote=False),
            preserveWhitespace(output),
        )
    def __call__(self):

        if self.request.method != 'POST':
            raise Unauthorized()

        line = self.request.form.get('line', '')
        if not line.strip():
            return ''

        line = line.rstrip() + '\n'

        portal = getToolByName(self.context, 'portal_url').getPortalObject()
        app = portal.getPhysicalRoot()

        globs = {
            'context': self.context,
            'request': self.request,
            'portal': portal,
            'app': app,
        }

        globs.update(VARS.get(self.context))
        context = evalcontext.EvalContext({}, globs)
        output = context.exec_expr(line)
        VARS.update(self.context, globs)

        line_html = formatter.str2html(line)
        return ('<code style="color: #060">&gt;&gt;&gt;</code> '
                '%s<br />\n%s' % (preserveWhitespace(
                    line_html, quote=False), preserveWhitespace(output)))
    def __call__(self):

        if self.request.method != 'POST':
            raise Unauthorized()
        
        line = self.request.form.get('line', '')
        if not line.strip():
            return ''
        
        line = line.rstrip() + '\n'
        
        portal = getToolByName(self.context, 'portal_url').getPortalObject()
        app = portal.getPhysicalRoot()
        
        globs = {
            'context': self.context,
            'request': self.request,
            'portal': portal,
            'app': app,
        }

        globs.update(VARS.get(self.context))
        context = evalcontext.EvalContext({}, globs)
        output = context.exec_expr(line)
        VARS.update(self.context, globs)

        line_html = formatter.str2html(line)
        return ('<code style="color: #060">&gt;&gt;&gt;</code> '
                '%s<br />\n%s'
                % (preserveWhitespace(line_html, quote=False),
                   preserveWhitespace(output)))
Пример #4
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)))
Пример #5
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)))