Beispiel #1
0
 def __init__(self, reactor, cap_table, http_endpoint, ws_endpoint, root_cap, title):
     # Constants
     self.__http_endpoint_string = str(http_endpoint)
     self.__http_endpoint = endpoints.serverFromString(reactor, self.__http_endpoint_string)
     self.__ws_endpoint = endpoints.serverFromString(reactor, str(ws_endpoint))
     self.__visit_path = _make_cap_url(root_cap)
     
     wcommon = WebServiceCommon(
         reactor=reactor,
         title=title,
         ws_endpoint_string=ws_endpoint)
     # TODO: Create poller actually for the given reactor w/o redundancy -- perhaps there should be a one-poller-per-reactor map
     subscription_context = SubscriptionContext(reactor=reactor, poller=the_poller)
     
     def resource_factory(entry_point):
         # TODO: If not an IWebEntryPoint, return a generic result
         return IWebEntryPoint(entry_point).get_entry_point_resource(wcommon=wcommon)  # pylint: disable=redundant-keyword-arg
     
     server_root = CapAccessResource(cap_table=cap_table, resource_factory=resource_factory)
     _put_root_static(wcommon, server_root)
     
     if UNIQUE_PUBLIC_CAP in cap_table:
         # TODO: consider factoring out "generate URL for cap"
         server_root.putChild('', Redirect(_make_cap_url(UNIQUE_PUBLIC_CAP)))
         
     self.__ws_protocol = txws.WebSocketFactory(
         FactoryWithArgs.forProtocol(WebSocketDispatcherProtocol, cap_table, subscription_context))
     self.__site = SiteWithDefaultHeaders(server_root)
     
     self.__ws_port_obj = None
     self.__http_port_obj = None
Beispiel #2
0
 def setUp(self):
     wcommon = WebServiceCommon.stub(reactor=the_reactor)
     self.obj = StateSpecimen()
     r = BlockResource(self.obj, wcommon, None)
     self.port = the_reactor.listenTCP(0,
                                       SiteWithDefaultHeaders(r),
                                       interface="127.0.0.1")  # pylint: disable=no-member
Beispiel #3
0
 def setUp(self):
     tree = Resource()
     tree.putChild('mono', AudioStreamResource(_FakeSession(1)))
     tree.putChild('stereo', AudioStreamResource(_FakeSession(2)))
     self.port = the_reactor.listenTCP(0,
                                       SiteWithDefaultHeaders(tree),
                                       interface="127.0.0.1")  # pylint: disable=no-member
Beispiel #4
0
 def setUp(self):
     db_model = db.DatabaseModel(reactor,
                                 dict(self.test_records),
                                 writable=True)
     dbResource = db.DatabaseResource(db_model)
     self.port = reactor.listenTCP(0,
                                   SiteWithDefaultHeaders(dbResource),
                                   interface="127.0.0.1")  # pylint: disable=no-member
Beispiel #5
0
 def setUp(self):
     db_model = db.DatabaseModel(reactor, {}, writable=True)
     dbs_resource = db.DatabasesResource({'foo&bar': db_model})
     self.port = reactor.listenTCP(0,
                                   SiteWithDefaultHeaders(dbs_resource),
                                   interface="127.0.0.1")  # pylint: disable=no-member