コード例 #1
0
ファイル: api.py プロジェクト: OnShift/PyProtocols
def declareAdapterForProtocol(protocol, adapter, proto, depth=1):
    """Declare that 'adapter' adapts 'proto' to 'protocol'"""
    adapt(protocol, IOpenProtocol)  # src and dest must support IOpenProtocol
    adapt(proto,
          IOpenProtocol).addImpliedProtocol(protocol,
                                            bindAdapter(adapter, protocol),
                                            depth)
コード例 #2
0
ファイル: api.py プロジェクト: OnShift/PyProtocols
def declareAdapterForType(protocol, adapter, typ, depth=1):
    """Declare that 'adapter' adapts instances of 'typ' to 'protocol'"""
    adapter = bindAdapter(adapter, protocol)
    adapter = adapt(protocol,
                    IOpenProtocol).registerImplementation(typ, adapter, depth)

    oi = adapt(typ, IOpenImplementor, None)

    if oi is not None:
        oi.declareClassImplements(protocol, adapter, depth)
コード例 #3
0
ファイル: api.py プロジェクト: OnShift/PyProtocols
def declareAdapterForType(protocol, adapter, typ, depth=1):
    """Declare that 'adapter' adapts instances of 'typ' to 'protocol'"""
    adapter = bindAdapter(adapter,protocol)
    adapter = adapt(protocol, IOpenProtocol).registerImplementation(
        typ, adapter, depth
    )

    oi = adapt(typ, IOpenImplementor, None)

    if oi is not None:
        oi.declareClassImplements(protocol,adapter,depth)
コード例 #4
0
ファイル: api.py プロジェクト: OnShift/PyProtocols
def declareAdapterForObject(protocol, adapter, ob, depth=1):
    """Declare that 'adapter' adapts 'ob' to 'protocol'"""
    adapt(protocol,IOpenProtocol).registerObject(ob,bindAdapter(adapter,protocol),depth)
コード例 #5
0
ファイル: api.py プロジェクト: OnShift/PyProtocols
def declareAdapterForProtocol(protocol, adapter, proto, depth=1):
    """Declare that 'adapter' adapts 'proto' to 'protocol'"""
    adapt(protocol, IOpenProtocol)  # src and dest must support IOpenProtocol
    adapt(proto, IOpenProtocol).addImpliedProtocol(protocol, bindAdapter(adapter,protocol), depth)
コード例 #6
0
ファイル: api.py プロジェクト: OnShift/PyProtocols
def declareAdapterForObject(protocol, adapter, ob, depth=1):
    """Declare that 'adapter' adapts 'ob' to 'protocol'"""
    adapt(protocol,
          IOpenProtocol).registerObject(ob, bindAdapter(adapter, protocol),
                                        depth)