Beispiel #1
0
 def __init__(self, environ):
     self.environ = environ
     self.path_info = wsgi.get_path_info(environ)
     self.script_name = wsgi.get_script_name(environ)
     self.path = "unknown"
     self.META = environ
     self.META['PATH_INFO'] = self.path_info
     self.META['SCRIPT_NAME'] = self.script_name
     self.method = environ['REQUEST_METHOD'].upper()
     self.status = ""
    def __call__(self, environ, start_response):
        # Hand non-static requests to Django
        if not self._should_handle(get_path_info(environ)):
            return self.application(environ, start_response)

        # Serve static requests from static.Cling
        if not self.debug:
            environ = self._transpose_environ(environ)
            return self.cling(environ, start_response)
        # Serve static requests in debug mode from StaticFilesHandler
        else:
            return self.debug_cling(environ, start_response)
    def __call__(self, environ, start_response):

        try:
            if get_path_info(environ) == self.login_url:
                username = self.process_authorization(environ)
                if username is None:
                    start_response('401 Unauthorized', [
                        ('Content-Type', self.message_type),
                        ('WWW-Authenticate', 'Basic realm="%s"' % self.realm),
                    ])
                    return [self.message]
        finally:
            close_old_connections()

        return self.application(environ, start_response)
Beispiel #4
0
    def __call__(self, environ, start_response):
        # Hand non-static requests to Django
        try:
            if not self._should_handle(get_path_info(environ)):
                return self.application(environ, start_response)
        except UnicodeDecodeError:
            # Apparently a malformed URL. Just hand it to Django
            # for it to respond as it sees fit.
            return self.application(environ, start_response)

        # Serve static requests from static.Cling
        if not self.debug or self.ignore_debug:
            environ = self._transpose_environ(environ)
            return self.cling(environ, start_response)
        # Serve static requests in debug mode from StaticFilesHandler
        else:
            return self.debug_cling(environ, start_response)
Beispiel #5
0
 def __call__(self, environ, start_response):
     if not self._should_handle(get_path_info(environ)):
         return self.application(environ, start_response)
     return super(FSFilesHandler, self).__call__(environ, start_response)
from django.conf import settings
Beispiel #7
0
 def __call__(self, environ, start_response):
     if not self._should_handle(get_path_info(environ)):
         return self.application(environ, start_response)
     return super(StaticFilesHandler,
                  self).__call__(environ, start_response)