|
Adapter and Declaration API
|
Imported modules
|
|
from adapters import NO_ADAPTER_NEEDED, DOES_NOT_SUPPORT, IMPLEMENTATION_ERROR
from advice import addClassAdvisor, getFrameInfo
from interfaces import IOpenProtocol, IOpenProvider, IOpenImplementor, Protocol, InterfaceClass
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,
factory=IMPLEMENTATION_ERROR,
)
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.
|
|
|
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
|
|