Table of Contents

Module: api ./src/protocols/api.py

Adapter and Declaration API

Imported modules   
from adapters import NO_ADAPTER_NEEDED, DOES_NOT_SUPPORT, AdaptationFailure, bindAdapter
from interfaces import IOpenProtocol, IOpenProvider, IOpenImplementor, Protocol, InterfaceClass
from peak.util.decorators import decorate_class, frameinfo
from sys import _getframe, exc_info, modules
from types import ClassType
Functions   
adapt
advise
adviseObject
declareAdapter
declareAdapterForObject
declareAdapterForProtocol
declareAdapterForType
declareImplementation
  adapt 
adapt (
        obj,
        protocol,
        default=_marker,
        )

PEP 246-alike: Adapt obj to protocol, return default

If default is not supplied and no implementation is found, the result of factory(obj,protocol) is returned. If factory is also not supplied, NotImplementedError is then raised.

Exceptions   
AdaptationFailure( "Can't adapt", obj, protocol )
  advise 
advise ( **kw )

Exceptions   
SyntaxError( "protocols.advise() must be called directly in a class or" " module body, not in a function or exec." )
TypeError( "'factoryMethod' is only used when declaring an adapter type" )
TypeError( "Invalid keyword argument for advising classes: %s" % k )
TypeError( "Invalid keyword argument for advising modules: %s" % k )
TypeError( "When declaring an adapter, you must specify what" " its instances will provide." )
  adviseObject 
adviseObject (
        ob,
        provides=(),
        doesNotProvide=(),
        )

Tell an object what it does or doesn't provide

  declareAdapter 
declareAdapter (
        factory,
        provides,
        forTypes=(),
        forProtocols=(),
        forObjects=(),
        )

factory is an IAdapterFactory providing provides protocols

  declareAdapterForObject 
declareAdapterForObject (
        protocol,
        adapter,
        ob,
        depth=1,
        )

Declare that adapter adapts ob to protocol

  declareAdapterForProtocol 
declareAdapterForProtocol (
        protocol,
        adapter,
        proto,
        depth=1,
        )

Declare that adapter adapts proto to protocol

  declareAdapterForType 
declareAdapterForType (
        protocol,
        adapter,
        typ,
        depth=1,
        )

Declare that adapter adapts instances of typ to protocol

  declareImplementation 
declareImplementation (
        typ,
        instancesProvide=(),
        instancesDoNotProvide=(),
        )

Declare information about a class, type, or IOpenImplementor


Table of Contents

This document was automatically generated on Mon Apr 22 01:11:13 2024 by HappyDoc version 2.1