Item Registration

Registering Items

Registration is simple. You only need to call Registry.register().

Make sure you’ve provided an object or class with a unique value for the registry’s lookup attributes.

For example:

from myproject.registry import BaseItem, my_registry


class MyNewItem(BaseItem):
    my_id = 'new-item'


my_registry.register(MyNewItem)

When registering, the following exceptions can be raised:

Unregistering Items

Items can be unregistered using one of two methods:

For example:

from myproject.registry import BaseItem, my_registry


class MyNewItem(BaseItem):
    my_id = 'new-item'

...

# Unregister the formerly-registered item.
my_registry.unregister(MyNewItem)

# Or unregister by attribute value (if the registry only uses a single
# lookup attribute).
my_registry.unregister_by_attr('new-item')

# Or unregister by specific lookup attributes:
my_registry.unregister_by_attr(my_id='new-item')

When unregistering, the following exceptions can be raised: