Package AccessEngine :: Module AEAccAdapter :: Class Interface
[hide private]
[frames] | no frames]

Class Interface

source code

object --+
         |
        Interface

Base class for all interfaces.

Acts as a factory for instantiating the proper registered adapter for the given Interface subclass and subject. For example, assume INavigable is a subclass of this class. The code:

adapted_object = INavigable(some_object)

will return an object adapting some_object to the INavigable interface if such and adapter exists. If some_object has an attribute called providesInterfaces which contains INavigable, the original object will be returned. If no suitable adapter exists, an exception is raised.

The _get function does most of the work in retrieving an appropriate adapter.

Instance Methods [hide private]
 
__new__(interface, subject=None)
Creates an adapter instance providing the given interface for the given subject.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(interface, subject=None)

source code 
Creates an adapter instance providing the given interface for the given subject.
Parameters:
  • interface (Interface) - Desired interface for the subject
  • subject (object) - Object to adapt to the interface
Returns:
a new object with type S, a subtype of T

Raises:
  • AdaptationError - When no suitable adapter exists to provide the desired interface for the given subject
Overrides: object.__new__