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


Python Resource.isLeaf方法代码示例

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


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

示例1: test_leafResource

# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import isLeaf [as 别名]
 def test_leafResource(self):
     """
     L{getChildForRequest} returns the first resource it encounters with a
     C{isLeaf} attribute set to C{True}.
     """
     request = DummyRequest([b"foo", b"bar"])
     resource = Resource()
     resource.isLeaf = True
     result = getChildForRequest(resource, request)
     self.assertIdentical(resource, result)
开发者ID:Architektor,项目名称:PySnip,代码行数:12,代码来源:test_resource.py

示例2: wrapper

# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import isLeaf [as 别名]
        def wrapper(fn):
            """

            :type path: str
            """
            r = Resource()
            r.render_GET = fn
            r.isLeaf = True
            self.routes[path] = r
            return fn
开发者ID:KurlesHS,项目名称:twised_angular_test,代码行数:12,代码来源:server.py

示例3: on_login

# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import isLeaf [as 别名]
 def on_login(_):
     logger.info("Logged in as '%s'", spotify.session.user_name)
     root = Resource()
     root.isLeaf = False
     player = Player(spotify)
     root.putChild("player",player)
     root.putChild("static",File(cfg.get("SERVER", "static")))
     site = Site(root)
     # setup and register service
     reactor.listenTCP(port, site)
     logger.info("Listening on %s:%d", host, port)
     zeroconf.register_service(service_info)
开发者ID:meteran,项目名称:tir-PiSpotify,代码行数:14,代码来源:spotify_server.py

示例4: test_postPathToPrePath

# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import isLeaf [as 别名]
 def test_postPathToPrePath(self):
     """
     As path segments from the request are traversed, they are taken from
     C{postpath} and put into C{prepath}.
     """
     request = DummyRequest([b"foo", b"bar"])
     root = Resource()
     child = Resource()
     child.isLeaf = True
     root.putChild(b"foo", child)
     self.assertIdentical(child, getChildForRequest(root, request))
     self.assertEqual(request.prepath, [b"foo"])
     self.assertEqual(request.postpath, [b"bar"])
开发者ID:Architektor,项目名称:PySnip,代码行数:15,代码来源:test_resource.py

示例5: make_real_webserver

# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import isLeaf [as 别名]
 def make_real_webserver(self):
     """
     Construct a real webserver to test actual connectivity.
     """
     root = Resource()
     root.isLeaf = True
     root.render = lambda r: self._render_request(r)
     site_factory = Site(root)
     webserver = yield reactor.listenTCP(
         0, site_factory, interface='127.0.0.1')
     self.add_cleanup(webserver.loseConnection)
     addr = webserver.getHost()
     url = "http://%s:%s/" % (addr.host, addr.port)
     returnValue(url)
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:16,代码来源:test_utils.py

示例6: render_GET

# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import isLeaf [as 别名]
    def render_GET(self, request):
        request.transport.socket.settimeout(5)
        if not getattr(twisted_bluetooth, "SCOReader", None):
            raise Exception("Not supported in your platform")

        address = request.path.split("/",2)[-1].replace("_", ":")
        if address == "" or len(address) != 17:
            raise Exception("Invalid address")
        scoclient = SCOStream(request)
        scoclient.process()
        scoclient.target = address
        if len(address) == 17:
            if not twisted_bluetooth.SCOConnected(address):
                log.msg("Connecting SCO to %s" % address)
                client = twisted_bluetooth.SCOReader(address,
                        self.gotFrame, self.lostConnection)
                log.msg("SCO connected")
        return server.NOT_DONE_YET

if __name__ == '__main__':
    from twisted.web.server import Site
    import sys
    log.startLogging(sys.stdout)

    root = Resource()
    root.isLeaf = False
    root.putChild("sco", SCOResource())
    reactor.listenTCP(8800, Site(root), interface="0.0.0.0")
    reactor.run()#!/usr/bin/env python

开发者ID:manuelnaranjo,项目名称:AIRi,代码行数:31,代码来源:sco.py


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