当前位置: 首页>>代码示例>>Python>>正文


Python wsgi.WSGIResource方法代码示例

本文整理汇总了Python中twisted.web.wsgi.WSGIResource方法的典型用法代码示例。如果您正苦于以下问题:Python wsgi.WSGIResource方法的具体用法?Python wsgi.WSGIResource怎么用?Python wsgi.WSGIResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.wsgi的用法示例。


在下文中一共展示了wsgi.WSGIResource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: boot_frontend

# 需要导入模块: from twisted.web import wsgi [as 别名]
# 或者: from twisted.web.wsgi import WSGIResource [as 别名]
def boot_frontend(config, debug=False):
    """
    Boot a Pyramid WSGI application as Twisted component
    """

    http_port = int(config.get('config-web', 'http_port'))
    websocket_uri = unicode(config.get('wamp', 'listen'))

    # https://stackoverflow.com/questions/13122519/serving-pyramid-application-using-twistd/13138610#13138610
    config = resource_filename('kotori.frontend', 'development.ini')
    application = get_app(config, 'main')

    # https://twistedmatrix.com/documents/13.1.0/web/howto/web-in-60/wsgi.html
    resource = WSGIResource(reactor, reactor.getThreadPool(), application)

    reactor.listenTCP(http_port, Site(resource)) 
开发者ID:daq-tools,项目名称:kotori,代码行数:18,代码来源:server.py

示例2: test_wsgi

# 需要导入模块: from twisted.web import wsgi [as 别名]
# 或者: from twisted.web.wsgi import WSGIResource [as 别名]
def test_wsgi(self):
        """
        The I{--wsgi} option takes the fully-qualifed Python name of a WSGI
        application object and creates a L{WSGIResource} at the root which
        serves that application.
        """
        options = Options()
        options.parseOptions(['--wsgi', __name__ + '.application'])
        root = options['root']
        self.assertTrue(root, WSGIResource)
        self.assertIdentical(root._reactor, reactor)
        self.assertTrue(isinstance(root._threadpool, ThreadPool))
        self.assertIdentical(root._application, application)

        # The threadpool should start and stop with the reactor.
        self.assertFalse(root._threadpool.started)
        reactor.fireSystemEvent('startup')
        self.assertTrue(root._threadpool.started)
        self.assertFalse(root._threadpool.joined)
        reactor.fireSystemEvent('shutdown')
        self.assertTrue(root._threadpool.joined) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:23,代码来源:test_tap.py

示例3: run

# 需要导入模块: from twisted.web import wsgi [as 别名]
# 或者: from twisted.web.wsgi import WSGIResource [as 别名]
def run(self, handler):
        from twisted.web import server, wsgi
        from twisted.python.threadpool import ThreadPool
        from twisted.internet import reactor
        thread_pool = ThreadPool()
        thread_pool.start()
        reactor.addSystemEventTrigger('after', 'shutdown', thread_pool.stop)
        factory = server.Site(wsgi.WSGIResource(reactor, thread_pool, handler))
        reactor.listenTCP(self.port, factory, interface=self.host)
        reactor.run() 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:12,代码来源:__init__.py

示例4: run

# 需要导入模块: from twisted.web import wsgi [as 别名]
# 或者: from twisted.web.wsgi import WSGIResource [as 别名]
def run(self, handler):
        from twisted.web import server, wsgi
        from twisted.python.threadpool import ThreadPool
        from twisted.internet import reactor
        thread_pool = ThreadPool()
        thread_pool.start()
        reactor.addSystemEventTrigger('after', 'shutdown', thread_pool.stop)
        factory = server.Site(wsgi.WSGIResource(reactor, thread_pool, handler))
        reactor.listenTCP(self.port, factory, interface=self.host)
        if not reactor.running:
            reactor.run() 
开发者ID:brycesub,项目名称:silvia-pi,代码行数:13,代码来源:bottle.py

示例5: opt_wsgi

# 需要导入模块: from twisted.web import wsgi [as 别名]
# 或者: from twisted.web.wsgi import WSGIResource [as 别名]
def opt_wsgi(self, name):
        """
        The FQPN of a WSGI application object to serve as the root resource of
        the webserver.
        """
        try:
            application = reflect.namedAny(name)
        except (AttributeError, ValueError):
            raise usage.UsageError("No such WSGI application: %r" % (name,))
        pool = threadpool.ThreadPool()
        reactor.callWhenRunning(pool.start)
        reactor.addSystemEventTrigger('after', 'shutdown', pool.stop)
        self['root'] = wsgi.WSGIResource(reactor, pool, application) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:tap.py

示例6: setUp

# 需要导入模块: from twisted.web import wsgi [as 别名]
# 或者: from twisted.web.wsgi import WSGIResource [as 别名]
def setUp(self):
        """
        Create a L{WSGIResource} with synchronous threading objects and a no-op
        application object.  This is useful for testing certain things about
        the resource implementation which are unrelated to WSGI.
        """
        self.resource = WSGIResource(
            SynchronousReactorThreads(), SynchronousThreadPool(),
            lambda environ, startResponse: None) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:test_wsgi.py

示例7: test_interfaces

# 需要导入模块: from twisted.web import wsgi [as 别名]
# 或者: from twisted.web.wsgi import WSGIResource [as 别名]
def test_interfaces(self):
        """
        L{WSGIResource} implements L{IResource} and stops resource traversal.
        """
        verifyObject(IResource, self.resource)
        self.assertTrue(self.resource.isLeaf) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_wsgi.py

示例8: test_unsupported

# 需要导入模块: from twisted.web import wsgi [as 别名]
# 或者: from twisted.web.wsgi import WSGIResource [as 别名]
def test_unsupported(self):
        """
        A L{WSGIResource} cannot have L{IResource} children.  Its
        C{getChildWithDefault} and C{putChild} methods raise L{RuntimeError}.
        """
        self.assertRaises(
            RuntimeError,
            self.resource.getChildWithDefault,
            b"foo", Request(DummyChannel(), False))
        self.assertRaises(
            RuntimeError,
            self.resource.putChild,
            b"foo", Resource()) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:test_wsgi.py


注:本文中的twisted.web.wsgi.WSGIResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。