# `classregistry`

####

classresolver.py
  2 February 2004, Ian Bicking <ianb@colorstudy.com>

The classregistry module is accessible via the `sqlobject` module.

Resolves strings to classes, and runs callbacks when referenced classes are created.

Classes are referred to only by name, not by module. So that identically-named classes can coexist, classes are put into individual registries, which are keyed on strings (names). These registries are created on demand.

Use like:

    >>> import classregistry
    >>> registry = classregistry.registry('MyModules')
    >>> def afterMyClassExists(cls):
    ...    print 'Class finally exists:', cls
    >>> registry.addClassCallback('MyClass', afterMyClassExists)
    >>> class MyClass:
    ...    pass
    >>> registry.addClass(MyClass)
    Class finally exists: MyClass

## Attributes

#### a `__package__`

    None

#### a `MasterRegistry`

    <sqlobject.classregistry._MasterRegistry object at 0xb4cc1ec>

## Functions

#### f `registry(self, item)` ...

#### f `findClass(name, class_registry=None)` ...

## Classes

#### C `ClassRegistry(...)` ...

We'll be dealing with classes that reference each other, so class C1 may reference C2 (in a join), while C2 references C1 right back. Since classes are created in an order, there will be a point when C1 exists but C2 doesn't. So we deal with classes by name, and after each class is created we try to fix up any references by replacing the names with actual classes.

Here we keep a dictionaries of class names to classes -- note that the classes might be spread among different modules, so since we pile them together names need to be globally unique, to just module unique. Like needSet below, the container dictionary is keyed by the class registry.

This class contains 9 members.

See the source for more information.