(self, environ, start_response)
Setup and handle a web request

        PylonsApp splits its functionality into several methods to
        make it easier to subclass and customize core functionality.

        The methods are called in the following order:

        1. :meth:`~PylonsApp.setup_app_env`
        2. :meth:`~PylonsApp.load_test_env` (Only if operating in
           testing mode)
        3. :meth:`~PylonsApp.resolve`
        4. :meth:`~PylonsApp.dispatch`

        The response from :meth:`~PylonsApp.dispatch` is expected to be
        an iterable (valid :pep:`333` WSGI response), which is then
        sent back as the response.
Setup and handle a web request
Setup and handle a web request
def __call__(self, environ, start_response):
        """Setup and handle a web request

        PylonsApp splits its functionality into several methods to
        make it easier to subclass and customize core functionality.

        The methods are called in the following order:

        1. :meth:`~PylonsApp.setup_app_env`
        2. :meth:`~PylonsApp.load_test_env` (Only if operating in
           testing mode)
        3. :meth:`~PylonsApp.resolve`
        4. :meth:`~PylonsApp.dispatch`

        The response from :meth:`~PylonsApp.dispatch` is expected to be
        an iterable (valid :pep:`333` WSGI response), which is then
        sent back as the response.

        """
        # Cache the logging level for the request
        log_debug = self.log_debug = logging.DEBUG >= log.getEffectiveLevel()
        environ['pylons.log_debug'] = log_debug

        self.setup_app_env(environ, start_response)
        if 'paste.testing_variables' in environ:
            self.load_test_env(environ)
            if environ['PATH_INFO'] == '/_test_vars':
                paste.registry.restorer.save_registry_state(environ)
                start_response('200 OK', [('Content-type', 'text/plain')])
                return ['%s' % paste.registry.restorer.get_request_id(environ)]

        controller = self.resolve(environ, start_response)
        response = self.dispatch(controller, environ, start_response)

        response_obj = callable(response)
        if 'paste.testing_variables' in environ and response_obj:
            environ['paste.testing_variables']['response'] = response

        try:
            if response_obj:
                return response(environ, start_response)
            elif response is not None:
                return response

            raise Exception("No content returned by controller (Did you "
                            "remember to 'return' it?) in: %r" %
                            controller.__name__)
        finally:
            # Help Python collect ram a bit faster by removing the reference
            # cycle that the pylons object causes
            if 'pylons.pylons' in environ:
                del environ['pylons.pylons']
def __call__ ( self , environ , start_response ) : # Cache the logging level for the request log_debug = self . log_debug = logging . DEBUG >= log . getEffectiveLevel ( ) environ [ 'pylons.log_debug' ] = log_debug self . setup_app_env ( environ , start_response ) if 'paste.testing_variables' in environ : self . load_test_env ( environ ) if environ [ 'PATH_INFO' ] == '/_test_vars' : paste . registry . restorer . save_registry_state ( environ ) start_response ( '200 OK' , [ ( 'Content-type' , 'text/plain' ) ] ) return [ '%s' % paste . registry . restorer . get_request_id ( environ ) ] controller = self . resolve ( environ , start_response ) response = self . dispatch ( controller , environ , start_response ) response_obj = callable ( response ) if 'paste.testing_variables' in environ and response_obj : environ [ 'paste.testing_variables' ] [ 'response' ] = response try : if response_obj : return response ( environ , start_response ) elif response is not None : return response raise Exception ( "No content returned by controller (Did you " "remember to 'return' it?) in: %r" % controller . __name__ ) finally : # Help Python collect ram a bit faster by removing the reference # cycle that the pylons object causes if 'pylons.pylons' in environ : del environ [ 'pylons.pylons' ]