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


Python interface.provider方法代码示例

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


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

示例1: __init__

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def __init__(self, logPath=None, timeout=_REQUEST_TIMEOUT,
                 logFormatter=None, reactor=None):
        """
        @param logFormatter: An object to format requests into log lines for
            the access log.
        @type logFormatter: L{IAccessLogFormatter} provider

        @param reactor: A L{IReactorTime} provider used to compute logging
            timestamps.
        """
        if not reactor:
            from twisted.internet import reactor
        self._reactor = reactor

        if logPath is not None:
            logPath = os.path.abspath(logPath)
        self.logPath = logPath
        self.timeOut = timeout
        if logFormatter is None:
            logFormatter = combinedLogFormatter
        self._logFormatter = logFormatter

        # For storing the cached log datetime and the callback to update it
        self._logDateTime = None
        self._logDateTimeCall = None 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:27,代码来源:http.py

示例2: __init__

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def __init__(self, connectedDeferred, wrappedProtocol):
        """
        @param connectedDeferred: The L{Deferred} that will callback
            with the C{wrappedProtocol} when it is connected.

        @param wrappedProtocol: An L{IProtocol} provider that will be
            connected.
        """
        self._connectedDeferred = connectedDeferred
        self._wrappedProtocol = wrappedProtocol

        for iface in [interfaces.IHalfCloseableProtocol,
                      interfaces.IFileDescriptorReceiver,
                      interfaces.IHandshakeListener]:
            if iface.providedBy(self._wrappedProtocol):
                directlyProvides(self, iface) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:endpoints.py

示例3: connect

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def connect(self, protocolFactory):
        """
        Implement L{IStreamClientEndpoint.connect} to launch a child process
        and connect it to a protocol created by C{protocolFactory}.

        @param protocolFactory: A factory for an L{IProtocol} provider which
            will be notified of all events related to the created process.
        """
        proto = protocolFactory.buildProtocol(_ProcessAddress())
        try:
            self._spawnProcess(
                _WrapIProtocol(proto, self._executable, self._errFlag),
                self._executable, self._args, self._env, self._path, self._uid,
                self._gid, self._usePTY, self._childFDs)
        except:
            return defer.fail()
        else:
            return defer.succeed(proto) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:endpoints.py

示例4: _parseServer

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def _parseServer(self, reactor, port, backlog=50, interface='::'):
        """
        Internal parser function for L{_parseServer} to convert the string
        arguments into structured arguments for the L{TCP6ServerEndpoint}

        @param reactor: An L{IReactorTCP} provider.

        @param port: The port number used for listening
        @type port: int

        @param backlog: Size of the listen queue
        @type backlog: int

        @param interface: The hostname to bind to
        @type interface: str
        """
        port = int(port)
        backlog = int(backlog)
        return TCP6ServerEndpoint(reactor, port, backlog, interface) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:endpoints.py

示例5: spawnProcess

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def spawnProcess(self, processProtocol, executable, args=(), env={},
                     path=None, uid=None, gid=None, usePTY=0, childFDs=None):
        """
        @ivar processProtocol: Stores the protocol passed to the reactor.
        @return: An L{IProcessTransport} provider.
        """
        self.processProtocol = processProtocol
        self.executable = executable
        self.args = args
        self.env = env
        self.path = path
        self.uid = uid
        self.gid = gid
        self.usePTY = usePTY
        self.childFDs = childFDs

        self.processTransport = MemoryProcessTransport()
        self.processProtocol.makeConnection(self.processTransport)
        return self.processTransport 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_endpoints.py

示例6: profiled_blockdevice_api

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def profiled_blockdevice_api(self):
        """
        Get an ``IProfiledBlockDeviceAPI`` provider which can create volumes
        configured based on pre-defined profiles. This will use the
        _underlying_blockdevice_api attribute, falling back to the
        block_device_api attributed and finally an adapter implementation
        around the block_device_api if neither of those provide the interface.
        """
        if IProfiledBlockDeviceAPI.providedBy(
                self._underlying_blockdevice_api):
            return self._underlying_blockdevice_api
        if IProfiledBlockDeviceAPI.providedBy(self.block_device_api):
            return self.block_device_api
        return ProfiledBlockDeviceAPIAdapter(
            _blockdevice_api=self.block_device_api
        ) 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:18,代码来源:blockdevice.py

示例7: async_block_device_api

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def async_block_device_api(self):
        """
        Get an ``IBlockDeviceAsyncAPI`` provider which can manipulate volumes
        for this deployer.

        During real operation, this is a threadpool-based wrapper around the
        ``IBlockDeviceAPI`` provider.  For testing purposes it can be
        overridden with a different object entirely (and this large amount of
        support code for this is necessary because this class is a ``PClass``
        subclass).
        """
        if self._async_block_device_api is None:
            return _SyncToThreadedAsyncAPIAdapter.from_api(
                self.block_device_api,
            )
        return self._async_block_device_api 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:18,代码来源:blockdevice.py

示例8: test_staticmethod_hit_on_class

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def test_staticmethod_hit_on_class(self):
        from zope.interface import Interface
        from zope.interface import provider
        from zope.interface.verify import verifyObject

        class IFoo(Interface):

            def bar(a, b):
                "The bar method"

        @provider(IFoo)
        class Foo(object):

            @staticmethod
            def bar(a, b):
                raise AssertionError("We're never actually called")

        # Don't use self._callFUT, we don't want to instantiate the
        # class.
        verifyObject(IFoo, Foo) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:22,代码来源:test_verify.py

示例9: getPeer

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def getPeer(self):
        """
        Get the remote address of this connection.

        @return: An L{IAddress} provider.
        """
        return self.transport.getPeer() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:http.py

示例10: getHost

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def getHost(self):
        """
        Get the local address of this connection.

        @return: An L{IAddress} provider.
        """
        return self.transport.getHost() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:9,代码来源:http.py

示例11: registerProducer

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def registerProducer(self, producer, streaming):
        """
        Register to receive data from a producer.

        This sets self to be a consumer for a producer.  When this object runs
        out of data (as when a send(2) call on a socket succeeds in moving the
        last data from a userspace buffer into a kernelspace buffer), it will
        ask the producer to resumeProducing().

        For L{IPullProducer} providers, C{resumeProducing} will be called once
        each time data is required.

        For L{IPushProducer} providers, C{pauseProducing} will be called
        whenever the write buffer fills up and C{resumeProducing} will only be
        called when it empties.

        @type producer: L{IProducer} provider
        @param producer: The L{IProducer} that will be producing data.

        @type streaming: L{bool}
        @param streaming: C{True} if C{producer} provides L{IPushProducer},
        C{False} if C{producer} provides L{IPullProducer}.

        @raise RuntimeError: If a producer is already registered.

        @return: L{None}
        """
        if self._requestProducer is not None:
            raise RuntimeError(
                "Cannot register producer %s, because producer %s was never "
                "unregistered." % (producer, self._requestProducer))

        if not streaming:
            producer = _PullToPush(producer, self)

        self._requestProducer = producer
        self._requestProducerStreaming = streaming

        if not streaming:
            producer.startStreaming() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:42,代码来源:http.py

示例12: makeConnection

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def makeConnection(self, process):
        """
        Call L{IProtocol} provider's makeConnection method with an
        L{ITransport} provider.

        @param process: An L{IProcessTransport} provider.
        """
        self.transport = _ProcessEndpointTransport(process)
        return self.protocol.makeConnection(self.transport) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:endpoints.py

示例13: processEnded

# 需要导入模块: from zope import interface [as 别名]
# 或者: from zope.interface import provider [as 别名]
def processEnded(self, reason):
        """
        If the process ends with L{error.ProcessDone}, this method calls the
        L{IProtocol} provider's L{connectionLost} with a
        L{error.ConnectionDone}

        @see: L{ProcessProtocol.processEnded}
        """
        if (reason.check(error.ProcessDone) == error.ProcessDone) and (
                reason.value.status == 0):
            return self.protocol.connectionLost(
                Failure(error.ConnectionDone()))
        else:
            return self.protocol.connectionLost(reason) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:endpoints.py


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