Adapter Registry

Usage of the adapter registry is documented in Adapter Registry.

The adapter registry’s API is defined by zope.interface.interfaces.IAdapterRegistry:

interface zope.interface.adapter.IAdapterRegistry[source]

Provide an interface-based registry for adapters

This registry registers objects that are in some sense “from” a sequence of specification to an interface and a name.

No specific semantics are assumed for the registered objects, however, the most common application will be to register factories that adapt objects providing required specifications to a provided interface.

register(required, provided, name, value)

Register a value

A value is registered for a sequence of required specifications, a provided interface, and a name, which must be text.

registered(required, provided, name=u'')

Return the component registered for the given interfaces and name

name must be text.

Unlike the lookup method, this methods won’t retrieve components registered for more specific required interfaces or less specific provided interfaces.

If no component was registered exactly for the given interfaces and name, then None is returned.

lookup(required, provided, name='', default=None)

Lookup a value

A value is looked up based on a sequence of required specifications, a provided interface, and a name, which must be text.

queryMultiAdapter(objects, provided, name=u'', default=None)

Adapt a sequence of objects to a named, provided, interface

lookup1(required, provided, name=u'', default=None)

Lookup a value using a single required interface

A value is looked up based on a single required specifications, a provided interface, and a name, which must be text.

queryAdapter(object, provided, name=u'', default=None)

Adapt an object using a registered adapter factory.

adapter_hook(provided, object, name=u'', default=None)

Adapt an object using a registered adapter factory.

name must be text.

lookupAll(required, provided)

Find all adapters from the required to the provided interfaces

An iterable object is returned that provides name-value two-tuples.

names(required, provided)

Return the names for which there are registered objects

subscribe(required, provided, subscriber, name=u'')

Register a subscriber

A subscriber is registered for a sequence of required specifications, a provided interface, and a name.

Multiple subscribers may be registered for the same (or equivalent) interfaces.

subscriptions(required, provided, name=u'')

Get a sequence of subscribers

Subscribers for a sequence of required interfaces, and a provided interface are returned.

subscribers(objects, provided, name=u'')

Get a sequence of subscription adapters