本文整理汇总了Python中twisted.web.resource.Resource._v1_user方法的典型用法代码示例。如果您正苦于以下问题:Python Resource._v1_user方法的具体用法?Python Resource._v1_user怎么用?Python Resource._v1_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.resource.Resource
的用法示例。
在下文中一共展示了Resource._v1_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_api_service
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import _v1_user [as 别名]
def create_api_service(persistence_service, cluster_state_service, endpoint,
context_factory, clock=reactor):
"""
Create a Twisted Service that serves the API on the given endpoint.
:param ConfigurationPersistenceService persistence_service: Service
for retrieving and setting desired configuration.
:param ClusterStateService cluster_state_service: Service that
knows about the current state of the cluster.
:param endpoint: Twisted endpoint to listen on.
:param context_factory: TLS context factory.
:param IReactorTime clock: The clock to use for time. By default
global reactor.
:return: Service that will listen on the endpoint using HTTP API server.
"""
api_root = Resource()
user = ConfigurationAPIUserV1(persistence_service, cluster_state_service,
clock)
api_root.putChild('v1', user.app.resource())
api_root._v1_user = user # For unit testing purposes, alas
return StreamServerEndpointService(
endpoint,
TLSMemoryBIOFactory(
context_factory,
False,
Site(api_root)
)
)
示例2: create_api_service
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import _v1_user [as 别名]
def create_api_service(persistence_service, cluster_state_service, endpoint):
"""
Create a Twisted Service that serves the API on the given endpoint.
:param ConfigurationPersistenceService persistence_service: Service
for retrieving and setting desired configuration.
:param ClusterStateService cluster_state_service: Service that
knows about the current state of the cluster.
:param endpoint: Twisted endpoint to listen on.
:return: Service that will listen on the endpoint using HTTP API server.
"""
api_root = Resource()
user = ConfigurationAPIUserV1(persistence_service, cluster_state_service)
api_root.putChild('v1', user.app.resource())
api_root._v1_user = user # For unit testing purposes, alas
return StreamServerEndpointService(endpoint, Site(api_root))