當前位置: 首頁>>代碼示例>>Python>>正文


Python wsgi.WSGIHandler方法代碼示例

本文整理匯總了Python中django.core.handlers.wsgi.WSGIHandler方法的典型用法代碼示例。如果您正苦於以下問題:Python wsgi.WSGIHandler方法的具體用法?Python wsgi.WSGIHandler怎麽用?Python wsgi.WSGIHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.core.handlers.wsgi的用法示例。


在下文中一共展示了wsgi.WSGIHandler方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def run(self):
        """
        Set up the live server and databases, and then loop over handling
        HTTP requests.
        """
        if self.connections_override:
            # Override this thread's database connections with the ones
            # provided by the main thread.
            for alias, conn in self.connections_override.items():
                connections[alias] = conn
        try:
            # Create the handler for serving static and media files
            handler = self.static_handler(_MediaFilesHandler(WSGIHandler()))
            self.httpd = self._create_server()
            # If binding to port zero, assign the port allocated by the OS.
            if self.port == 0:
                self.port = self.httpd.server_address[1]
            self.httpd.set_app(handler)
            self.is_ready.set()
            self.httpd.serve_forever()
        except Exception as e:
            self.error = e
            self.is_ready.set()
        finally:
            connections.close_all() 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:27,代碼來源:testcases.py

示例2: run

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def run(self):
        """
        Set up the live server and databases, and then loop over handling
        HTTP requests.
        """
        try:
            # Create the handler for serving static and media files
            self.httpd = self._create_server()
            # If binding to port zero, assign the port allocated by the OS.
            if self.port == 0:
                self.port = self.httpd.server_address[1]
            self.httpd.set_app(WSGIHandler())
            self.is_ready.set()
            self.httpd.serve_forever()
        except Exception as e:
            self.error = e
            self.is_ready.set() 
開發者ID:ansible-community,項目名稱:ara,代碼行數:19,代碼來源:offline.py

示例3: run

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def run(self):
        """
        Sets up the live server and databases, and then loops over handling
        http requests.
        """
        if self.connections_override:
            # Override this thread's database connections with the ones
            # provided by the main thread.
            for alias, conn in self.connections_override.items():
                connections[alias] = conn
        try:
            # Create the handler for serving static and media files
            handler = self.static_handler(_MediaFilesHandler(WSGIHandler()))
            self.httpd = self._create_server()
            # If binding to port zero, assign the port allocated by the OS.
            if self.port == 0:
                self.port = self.httpd.server_address[1]
            self.httpd.set_app(handler)
            self.is_ready.set()
            self.httpd.serve_forever()
        except Exception as e:
            self.error = e
            self.is_ready.set()
        finally:
            connections.close_all() 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:27,代碼來源:testcases.py

示例4: test_get_response_sends_signal_on_serialization_failures

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def test_get_response_sends_signal_on_serialization_failures(self):
        get_response = self.patch(WSGIHandler, "get_response")
        get_response.side_effect = (
            lambda request: self.cause_serialization_failure()
        )

        send_request_exception = self.patch_autospec(
            signals.got_request_exception, "send"
        )

        handler = views.WebApplicationHandler(1)
        request = make_request()
        request.path = factory.make_name("path")
        handler.get_response(request)

        self.assertThat(
            send_request_exception,
            MockCalledOnceWith(
                sender=views.WebApplicationHandler, request=request
            ),
        ) 
開發者ID:maas,項目名稱:maas,代碼行數:23,代碼來源:test_views.py

示例5: test_get_response_sends_signal_on_deadlock_failures

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def test_get_response_sends_signal_on_deadlock_failures(self):
        get_response = self.patch(WSGIHandler, "get_response")
        get_response.side_effect = make_deadlock_failure()

        send_request_exception = self.patch_autospec(
            signals.got_request_exception, "send"
        )

        handler = views.WebApplicationHandler(1)
        request = make_request()
        request.path = factory.make_name("path")
        handler.get_response(request)

        self.assertThat(
            send_request_exception,
            MockCalledOnceWith(
                sender=views.WebApplicationHandler, request=request
            ),
        ) 
開發者ID:maas,項目名稱:maas,代碼行數:21,代碼來源:test_views.py

示例6: test_get_response_is_in_retry_context_in_transaction

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def test_get_response_is_in_retry_context_in_transaction(self):
        handler = views.WebApplicationHandler(2)

        def check_retry_context_active(request):
            self.assertThat(retry_context.active, Is(True))

        get_response = self.patch(WSGIHandler, "get_response")
        get_response.side_effect = check_retry_context_active

        request = make_request()
        request.path = factory.make_name("path")

        self.assertThat(retry_context.active, Is(False))
        handler.get_response(request)
        self.assertThat(retry_context.active, Is(False))
        self.assertThat(get_response, MockCalledOnceWith(request)) 
開發者ID:maas,項目名稱:maas,代碼行數:18,代碼來源:test_views.py

示例7: get_handler

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def get_handler(self, *args, **options):
        """
        Returns the django.contrib.staticfiles handler.
        """
        handler = WSGIHandler()
        try:
            from django.contrib.staticfiles.handlers import StaticFilesHandler
        except ImportError:
            return handler
        use_static_handler = options.get('use_static_handler')
        insecure_serving = options.get('insecure_serving', False)
        if (settings.DEBUG and use_static_handler or
                (use_static_handler and insecure_serving)):
            handler = StaticFilesHandler(handler)
        return handler 
開發者ID:abarto,項目名稱:tracker_project,代碼行數:17,代碼來源:socketio_runserver.py

示例8: make_wsgi_application

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def make_wsgi_application():
    # validate models
    s = StringIO()
    if get_validation_errors(s):
        s.seek(0)
        error = s.read()
        msg = "One or more models did not validate:\n%s" % error
        print(msg, file=sys.stderr)
        sys.stderr.flush()
        sys.exit(1)

    translation.activate(settings.LANGUAGE_CODE)
    if django14:
        return get_internal_wsgi_application()
    return WSGIHandler() 
開發者ID:jpush,項目名稱:jbox,代碼行數:17,代碼來源:django_wsgi.py

示例9: get_wsgi_application

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def get_wsgi_application():
    """
    The public interface to Django's WSGI support. Should return a WSGI
    callable.

    Allows us to avoid making django.core.handlers.WSGIHandler public API, in
    case the internal WSGI implementation changes or moves in the future.

    """
    django.setup()
    return WSGIHandler() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:13,代碼來源:wsgi.py

示例10: get_wsgi_application

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def get_wsgi_application():
    """
    The public interface to Django's WSGI support. Should return a WSGI
    callable.

    Allows us to avoid making django.core.handlers.WSGIHandler public API, in
    case the internal WSGI implementation changes or moves in the future.

    """
    return WSGIHandler() 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:12,代碼來源:wsgi.py

示例11: run

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def run(self, netloc='0.0.0.0:9090', reload=True, log=True):
        """Run the CherryPy server."""
        from django.conf import settings
        from django.core.handlers.wsgi import WSGIHandler
        from paste.translogger import TransLogger

        url_parts = urlparse.urlsplit(netloc)
        host = "0.0.0.0"
        port = 9090
        cherrypy.config.update({
            'server.socket_host': host,
            'server.socket_port': port,
            'log.screen': False,
            'engine.autoreload.on': reload,
            'log.access_file': cherry_access_log,
            'log.error_file': cherry_error_log,
        })
        self.cfg_assets(settings.MEDIA_URL, settings.MEDIA_ROOT)
        self.cfg_assets(settings.STATIC_URL, settings.STATIC_ROOT)
        self.cfg_favicon(settings.STATIC_ROOT)
        app = WSGIHandler()
        app = TransLogger(app, logger_name='cherrypy.access',
                          setup_console_handler=False)
        if self.domains:
            app = cherrypy.wsgi.VirtualHost(app, self.domains)
        cherrypy.tree.graft(app)
        cherrypy.engine.start() 
開發者ID:diegojromerolopez,項目名稱:djanban,代碼行數:29,代碼來源:desktop_app_main.py

示例12: run

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def run(self):
        """
        Sets up the live server and databases, and then loops over handling
        http requests.
        """
        if self.connections_override:
            # Override this thread's database connections with the ones
            # provided by the main thread.
            for alias, conn in self.connections_override.items():
                connections[alias] = conn
        try:
            # Create the handler for serving static and media files
            handler = self.static_handler(_MediaFilesHandler(WSGIHandler()))

            # Go through the list of possible ports, hoping that we can find
            # one that is free to use for the WSGI server.
            for index, port in enumerate(self.possible_ports):
                try:
                    self.httpd = self._create_server(port)
                except socket.error as e:
                    if (index + 1 < len(self.possible_ports) and
                            e.errno == errno.EADDRINUSE):
                        # This port is already in use, so we go on and try with
                        # the next one in the list.
                        continue
                    else:
                        # Either none of the given ports are free or the error
                        # is something else than "Address already in use". So
                        # we let that error bubble up to the main thread.
                        raise
                else:
                    # A free port was found.
                    self.port = port
                    break

            self.httpd.set_app(handler)
            self.is_ready.set()
            self.httpd.serve_forever()
        except Exception as e:
            self.error = e
            self.is_ready.set() 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:43,代碼來源:testcases.py

示例13: __init__

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def __init__(self):
            self.app = WSGIHandler()
            self.factory = DjangoRequestFactory() 
開發者ID:BeanWei,項目名稱:Dailyfresh-B2C,代碼行數:5,代碼來源:test.py

示例14: test_assert_application

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def test_assert_application(self):
        self.assertIsInstance(application, WSGIHandler) 
開發者ID:luanfonceca,項目名稱:speakerfight,代碼行數:4,代碼來源:test_wsgi.py

示例15: test_data_upload_max_memory_size_exceeded

# 需要導入模塊: from django.core.handlers import wsgi [as 別名]
# 或者: from django.core.handlers.wsgi import WSGIHandler [as 別名]
def test_data_upload_max_memory_size_exceeded(self):
        response = WSGIHandler()(self.get_suspicious_environ(), lambda *a, **k: None)
        self.assertEqual(response.status_code, 400) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:5,代碼來源:test_exception.py


注:本文中的django.core.handlers.wsgi.WSGIHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。