本文整理匯總了Python中django.core.servers.basehttp.get_internal_wsgi_application方法的典型用法代碼示例。如果您正苦於以下問題:Python basehttp.get_internal_wsgi_application方法的具體用法?Python basehttp.get_internal_wsgi_application怎麽用?Python basehttp.get_internal_wsgi_application使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.core.servers.basehttp
的用法示例。
在下文中一共展示了basehttp.get_internal_wsgi_application方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_default
# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import get_internal_wsgi_application [as 別名]
def test_default(self):
"""
If ``WSGI_APPLICATION`` is ``None``, the return value of
``get_wsgi_application`` is returned.
"""
# Mock out get_wsgi_application so we know its return value is used
fake_app = object()
def mock_get_wsgi_app():
return fake_app
from django.core.servers import basehttp
_orig_get_wsgi_app = basehttp.get_wsgi_application
basehttp.get_wsgi_application = mock_get_wsgi_app
try:
app = get_internal_wsgi_application()
self.assertIs(app, fake_app)
finally:
basehttp.get_wsgi_application = _orig_get_wsgi_app
示例2: handle
# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import get_internal_wsgi_application [as 別名]
def handle(self, *args, **options):
m = re.match(naiveip_re, options['addrport'])
if m is None:
raise CommandError('"%s" is not a valid port number '
'or address:port pair.' % options['addrport'])
addr, _ipv4, _ipv6, _fqdn, port = m.groups()
if not port.isdigit():
raise CommandError("%r is not a valid port number." % port)
if addr:
if _ipv6:
raise CommandError('IPv6 addresses are currently not supported.')
application = get_internal_wsgi_application()
server = Server(application)
for file in os.listdir('.'):
if file[0] != '.' and file[:2] != '__' and os.path.isdir(file):
server.watch(file)
server.serve(host=addr, port=port, liveport=options['liveport'])
示例3: make_wsgi_application
# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import get_internal_wsgi_application [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()
示例4: get_handler
# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import get_internal_wsgi_application [as 別名]
def get_handler(self, *args, **options):
"""
Returns the default WSGI handler for the runner.
"""
return get_internal_wsgi_application()
示例5: test_success
# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import get_internal_wsgi_application [as 別名]
def test_success(self):
"""
If ``WSGI_APPLICATION`` is a dotted path, the referenced object is
returned.
"""
app = get_internal_wsgi_application()
from .wsgi import application
self.assertIs(app, application)
示例6: test_bad_module
# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import get_internal_wsgi_application [as 別名]
def test_bad_module(self):
msg = "WSGI application 'wsgi.noexist.app' could not be loaded; Error importing"
with self.assertRaisesMessage(ImproperlyConfigured, msg):
get_internal_wsgi_application()
示例7: test_bad_name
# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import get_internal_wsgi_application [as 別名]
def test_bad_name(self):
msg = "WSGI application 'wsgi.wsgi.noexist' could not be loaded; Error importing"
with self.assertRaisesMessage(ImproperlyConfigured, msg):
get_internal_wsgi_application()