Package logilab :: Package common :: Module registry :: Class Registry
[frames] | no frames]

Class Registry

source code

object --+    
         |    
      dict --+
             |
            Registry

The registry store a set of implementations associated to identifier:

* to each identifier are associated a list of implementations

* to select an implementation of a given identifier, you should use one of the
  :meth:`select` or :meth:`select_or_none` method

* to select a list of implementations for a context, you should use the
  :meth:`possible_objects` method

* dictionary like access to an identifier will return the bare list of
  implementations for this identifier.

To be usable in a registry, the only requirement is to have a `__select__`
attribute.

At the end of the registration process, the :meth:`__registered__`
method is called on each registered object which have them, given the
registry in which it's registered as argument.

Registration methods:

.. automethod: register
.. automethod: unregister

Selection methods:

.. automethod: select
.. automethod: select_or_none
.. automethod: possible_objects
.. automethod: object_by_id

Instance Methods
new empty dictionary

__init__(self, debugmode)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__getitem__(self, name)
return the registry (list of implementation objects) associated to...
source code
 
initialization_completed(self) source code
 
register(self, obj, oid=None, clear=False)
base method to add an object in the registry
source code
 
register_and_replace(self, obj, replaced) source code
 
unregister(self, obj) source code
 
all_objects(self)
return a list containing all objects in this registry.
source code
 
object_by_id(self, oid, *args, **kwargs)
return object with the `oid` identifier.
source code
 
select(self, __oid, *args, **kwargs)
return the most specific object among those with the given oid according to the given context.
source code
 
select_or_none(self, __oid, *args, **kwargs)
return the most specific object among those with the given oid according to the given context, or None if no object applies.
source code
 
possible_objects(self, *args, **kwargs)
return an iterator on possible objects in this registry for the given...
source code

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __setitem__, __sizeof__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values, viewitems, viewkeys, viewvalues

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __str__, __subclasshook__

Class Variables
  debug = lambda msg,* a,** kw:
  exception = lambda msg,* a,** kw:
  critical = lambda msg,* a,** kw:
  error = lambda msg,* a,** kw:
  warning = lambda msg,* a,** kw:
  info = lambda msg,* a,** kw:

Inherited from dict: __hash__

Properties

Inherited from object: __class__

Method Details

__init__(self, debugmode)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Returns:
new empty dictionary

Overrides: object.__init__
(inherited documentation)

__getitem__(self, name)
(Indexing operator)

source code 
return the registry (list of implementation objects) associated to
this name

Overrides: dict.__getitem__

object_by_id(self, oid, *args, **kwargs)

source code 
return object with the `oid` identifier. Only one object is expected
to be found.

raise :exc:`ObjectNotFound` if not object with id <oid> in <registry>

raise :exc:`AssertionError` if there is more than one object there

select(self, __oid, *args, **kwargs)

source code 
return the most specific object among those with the given oid
according to the given context.

raise :exc:`ObjectNotFound` if not object with id <oid> in <registry>

raise :exc:`NoSelectableObject` if not object apply

possible_objects(self, *args, **kwargs)

source code 
return an iterator on possible objects in this registry for the given
context