Пример #1
0
    def dorequest(self, request, body=None, chunk=None, trailers=None):
        """:meth:`pluggdapps.interfaces.IWebApps.dorequest` interface method."""
        self.pa.logdebug(
            "[%s] %s %s" %
            (request.method, request.uri, request.httpconn.address))

        try:
            # Initialize framework attributes
            request.router = self.router
            request.cookie = self.cookie
            # TODO : Initialize session attribute here.
            request.response = response = \
              self.qp( IHTTPResponse, self['IHTTPResponse'], request )
            request.handle(body=body, chunk=chunk, trailers=trailers)
            self.router.route(request)
        except:
            self.pa.logerror(h.print_exc())
            response.set_header('content_type', b'text/html')
            if self['debug']:
                data = self.livedebug.render(request, *sys.exc_info())
                response.set_status(b'200')
            else:
                response.set_status(b'500')
                data = ("An error occurred.  See the error logs for more "
                        "information. (Turn debug on to display exception "
                        "reports here)")
            response.write(data)
            response.flush(finishing=True)
Пример #2
0
    def dorequest( self, request, body=None, chunk=None, trailers=None ):
        """:meth:`pluggdapps.interfaces.IWebApps.dorequest` interface method."""
        self.pa.logdebug( 
          "[%s] %s %s" % (request.method,request.uri,request.httpconn.address))

        try :
            # Initialize framework attributes
            request.router = self.router
            request.cookie = self.cookie
            # TODO : Initialize session attribute here.
            request.response = response = \
              self.qp( IHTTPResponse, self['IHTTPResponse'], request )
            request.handle( body=body, chunk=chunk, trailers=trailers )
            self.router.route( request )
        except :
            self.pa.logerror( h.print_exc() )
            response.set_header( 'content_type', b'text/html' )
            if self['debug'] :
                data = self.livedebug.render( request, *sys.exc_info() )
                response.set_status( b'200' )
            else :
                response.set_status( b'500' )
                data = ( "An error occurred.  See the error logs for more "
                         "information. (Turn debug on to display exception "
                         "reports here)" )
            response.write( data )
            response.flush( finishing=True )
Пример #3
0
def frame_debug( request, c ):
    frame_index = request.webapp.livedebug.frame_index 
    frameid = request.matchdict['frameid']
    response = request.response
    if frameid not in frame_index :
        response.set_status( b'404' )
    else :
        try :
            expression = request.params['expression'][0]
            result = eval( expression, *frame_index[frameid] )
            response.write( pprint.pformat( result ))
        except :
            request.pa.logerror( h.print_exc() )
            response.set_status( b'500' )
    response.flush( finishing=True )
Пример #4
0
def put_config( request, c ):
    response = request.response
    netpath = request.matchdict.get( 'netpath', 'platform' )
    section = request.matchdict.get( 'section', None )
    name = request.params.get( 'key', None )
    value = request.params.get( 'value', None )
    try :
        if name and value :
            name = name[0].strip()
            value = value[0].strip()
            value = value if value != '-' else None
        if name and value :
            request.pa.config(
                    netpath=netpath, section=section, name=name, value=value )
    except :
        request.pa.logerror( h.print_exc() )
        response.set_status(406)
    response.flush( finishing=True )