Logo Search packages:      
Sourcecode: zine version File versions  Download package

def zine::application::Zine::dispatch_wsgi (   self,
  environ,
  start_response 
)

This method is the internal WSGI request and is overridden by
middlewares applied with :meth:`add_middleware`.  It handles the
actual request dispatching.

Definition at line 1187 of file application.py.

01187                                                     :
        """This method is the internal WSGI request and is overridden by
        middlewares applied with :meth:`add_middleware`.  It handles the
        actual request dispatching.
        """
        # Create a new request object, register it with the application
        # and all the other stuff on the current thread but initialize
        # it afterwards.  We do this so that the request object can query
        # the database in the initialization method.
        request = object.__new__(Request)
        local.request = request
        local.page_metadata = []
        local.request_locals = {}
        request.__init__(environ, self)

        # check if the blog is in maintenance_mode and the user is
        # not an administrator. in that case just show a message that
        # the user is not privileged to view the blog right now. Exception:
        # the page is the login page for the blog.
        admin_prefix = self.cfg['admin_url_prefix']
        if self.cfg['maintenance_mode'] and \
           request.path != admin_prefix and not \
           request.path.startswith(admin_prefix + '/'):
            if not request.user.is_admin:
                response = render_response('maintenance.html')
                response.status_code = 503
                return response(environ, start_response)

        # wrap the real dispatching in a try/except so that we can
        # intercept exceptions that happen in the application.
        try:
            response = self.dispatch_request(request)

            # make sure the response object is one of ours
            response = Response.force_type(response, environ)

            #! allow plugins to change the response object
            for callback in iter_listeners('before-response-processed'):
                result = callback(response)
                if result is not None:
                    response = result
        except InternalError, e:
            response = self.handle_internal_error(request, e)
        except:
            if self.cfg['passthrough_errors']:
                raise
            response = self.handle_server_error(request)

        # update the session cookie at the request end if the
        # session data requires an update.
        if request.session.should_save:
            cookie_name = self.cfg['session_cookie_name']
            if request.session.get('pmt'):
                max_age = 60 * 60 * 24 * 31
                expires = time() + max_age
            else:
                max_age = expires = None
            request.session.save_cookie(response, cookie_name, max_age=max_age,
                                        expires=expires, session_expires=expires)

        return response(environ, start_response)

    def __call__(self, environ, start_response):


Generated by  Doxygen 1.6.0   Back to index