# `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.

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

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.

## Methods

#### f `__format__(...)` ...

default object formatter

#### f `__subclasshook__(...)` ...

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

#### f `__sizeof__(...)` ...

__sizeof__() -> int size of object in memory, in bytes

#### f `__init__(self, name)` ...

#### f `addClassCallback(self, className, callback, *args, **kw)` ...

Whenever a name is substituted for the class, you can register a callback that will be called when the needed class is created. If it's already been created, the callback will be called immediately.

#### f `addCallback(self, callback, *args, **kw)` ...

This callback is called for all classes, not just specific ones (like addClassCallback).

#### f `addClass(self, cls)` ...

Everytime a class is created, we add it to the registry, so that other classes can find it by name. We also call any callbacks that are waiting for the class.

#### f `getClass(self, className)` ...

#### f `allClasses(self)` ...

See the source for more information.