本文整理汇总了Python中twisted.web.resource.Resource.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.__init__方法的具体用法?Python Resource.__init__怎么用?Python Resource.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.resource.Resource
的用法示例。
在下文中一共展示了Resource.__init__方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self):
Resource.__init__(self)
log.info('Initializing HttpChannelContainer')
# Reference to Metastore database.
self.metastore = None
# HTTP routing callbacks.
self.callbacks = {}
# Connect to Metastore database.
self.database_connect()
# Initialize routing engine.
self.router = PathRoutingEngine()
示例2: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, host, port, path, reactor=reactor):
"""
@param host: the host of the web server to proxy.
@type host: C{str}
@param port: the port of the web server to proxy.
@type port: C{port}
@param path: the base path to fetch data from. Note that you shouldn't
put any trailing slashes in it, it will be added automatically in
request. For example, if you put B{/foo}, a request on B{/bar} will
be proxied to B{/foo/bar}. Any required encoding of special
characters (such as " " or "/") should have been done already.
@type path: C{str}
"""
Resource.__init__(self)
self.host = host
self.port = port
self.path = path
self.reactor = reactor
示例3: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, host, port, path, reactor=reactor):
"""
@param host: the host of the web server to proxy.
@type host: C{str}
@param port: the port of the web server to proxy.
@type port: C{port}
@param path: the base path to fetch data from. Note that you shouldn't
put any trailing slashes in it, it will be added automatically in
request. For example, if you put B{/foo}, a request on B{/bar} will
be proxied to B{/foo/bar}. Any required encoding of special
characters (such as " " or "/") should have been done already.
@type path: C{bytes}
"""
Resource.__init__(self)
self.host = host
self.port = port
self.path = path
self.reactor = reactor
示例4: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, factory):
self.factory = factory
self.skin = self.factory.skin
self.skindir = self.factory.skindir
if not os.path.isdir(self.skindir):
raise Exception(
"Directory %s for http skin, %s, does not exist."
% (self.skindir, self.skin))
with open(os.path.join(self.skindir, "index.html")) as f:
text = f.read()
p = re.compile(r"<!--STARTERR-->.*<!--ENDERR-->", re.DOTALL)
self.login = re.sub(p, "", text)
self.err = re.sub(r"<!--STARTERR-->|<!--ENDERR-->", "", text)
Resource.__init__(self)
示例5: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, reactor, timeoutSeconds, becameInactive):
"""
@param reactor: the reactor
@timeoutSeconds: the number of seconds considered to mean inactive
@becameInactive: the method to call (with no arguments) when
inactivity is reached
"""
self._reactor = reactor
self._timeoutSeconds = timeoutSeconds
self._becameInactive = becameInactive
if self._timeoutSeconds > 0:
self._delayedCall = self._reactor.callLater(
self._timeoutSeconds,
self._inactivityThresholdReached
)
示例6: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, dockerAddr=None, dockerPort=None, dockerSocket=None,
path='', reactor=reactor, config=None):
"""
A docker proxy resource which knows how to connect to real Docker
daemon either via socket (dockerSocket specified) or address + port for
TCP connection (dockerAddr + dockerPort specified).
"""
if config is None:
# Try to get the configuration from the default place on the
# filesystem.
self.config = PluginConfiguration()
else:
self.config = config
self.config.read_and_parse()
self.parser = EndpointParser(self.config)
Resource.__init__(self)
self.host = dockerAddr
self.port = dockerPort
self.socket = dockerSocket
self.path = path
self.reactor = reactor
proxy.ReverseProxyResource.__init__(self, dockerAddr, dockerPort, path, reactor) # NB dockerAddr is not actually used
self.agent = Agent(reactor) # no connectionpool
self.client = HTTPClient(self.agent)
示例7: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, service, noAuthResource, authResourceFactory, callback=None):
"""Create a PerspectiveWrapper.
@type service: C{twisted.cred.service.Service}
@type noAuthResource: C{Resource}
@type authResourceFactory: a callable object
@param authResourceFactory: This should be a function which takes as an
argument perspective from 'service' and returns a
C{Resource} instance.
@param noAuthResource: This parameter is the C{Resource} that is used
when the user is browsing this site anonymously. Somewhere accessible
from this should be a link to 'perspective-init', which will display a
C{form.FormProcessor} that allows the user to log in.
"""
warnings.warn("Please use UsernamePasswordWrapper instead", DeprecationWarning, 2)
Resource.__init__(self)
self.service = service
self.noAuthResource = noAuthResource
self.authResourceFactory = authResourceFactory
self.callback = callback
示例8: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, db):
Resource.__init__(self)
self.db = db
示例9: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, received):
self.received = received
Resource.__init__(self)
示例10: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, dispatcher, global_tokens):
Resource.__init__(self)
self.dispatcher = dispatcher
self.global_tokens = global_tokens
示例11: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, websocket_uri, filename):
Resource.__init__(self)
self.websocket_uri = websocket_uri
self.filename = filename
示例12: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, api):
self.started = datetime.now()
self.api = api
self.output = api.output
self.root = Resource()
self.commands = [name[5:]
for name in dir(self) if name.startswith('json_')]
for route in self.commands:
self.root.putChild(route, Leaf(
self, getattr(self, 'json_%s' % route)))
示例13: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, conf, db, agent, clients):
# type: (AutopushConfig, DatabaseManager, Agent, Dict) -> None
WebSocketServerFactory.__init__(self, conf.ws_url)
self.conf = conf
self.db = db
self.agent = agent
self.clients = clients
self.setProtocolOptions(
webStatus=False,
openHandshakeTimeout=5,
autoPingInterval=conf.auto_ping_interval,
autoPingTimeout=conf.auto_ping_timeout,
maxConnections=conf.max_connections,
closeHandshakeTimeout=conf.close_handshake_timeout,
)
示例14: __init__
# 需要导入模块: from twisted.web.resource import Resource [as 别名]
# 或者: from twisted.web.resource.Resource import __init__ [as 别名]
def __init__(self, syd):
Resource.__init__(self)
self.sydent = syd