Jump to >

djblets.configforms.registry

A registry for configuration forms and pages.

class ConfigPageFormRegistry[source]

Bases: djblets.registries.registry.OrderedRegistry

A registry for managing configuration page forms.

lookup_attrs: Sequence[str] = ('form_id',)[source]

A list of attributes that items can be looked up by.

Type

list of str

default_errors: Dict[str, str] = {'already_registered': 'Could not register form %(item)r: This form is already registered.', 'attribute_registered': 'Could not register form %(item)r: Another form (%(duplicate)r) is already registered with %(attr_name)s = %(attr_value)s.', 'invalid_attribute': '"%(attr_name)s" is not a registered lookup attribute.', 'load_entry_point': 'Could not load entry point %(entry_point)s: %(error)s.', 'missing_attribute': 'Could not register %(item)s: it does not have a "%(attr_name)s" attribute.', 'not_registered': 'No item registered with %(attr_name)s = %(attr_value)s.', 'unregister': 'Could not unregister %(item)s: it is not registered.'}[source]

The default error formatting strings.

If subclasses need to provide additional errors that can be overridden, they should copy DEFAULT_ERRORS and set their copy on the subclass as this attribute.

Type

dict

__annotations__ = {'_by_id': 'Dict[int, RegistryItemType]', '_items': 'Set[RegistryItemType]', '_key_order': 'List[int]', '_populated': 'bool', '_registry': 'Dict[str, Dict[object, RegistryItemType]]', 'already_registered_error_class': 'Type[AlreadyRegisteredError]', 'default_errors': 'Dict[str, str]', 'errors': 'Dict[str, str]', 'item_name': 'Optional[str]', 'lookup_attrs': 'Sequence[str]', 'lookup_error_class': 'Type[ItemLookupError]'}
__parameters__ = ()
class ConfigPageRegistry[source]

Bases: djblets.registries.registry.OrderedRegistry

A registry for managing configuration pages.

This allows subclasses to dynamically change which pages are available, as well as which forms are available on each page.

The pages managed by this registry must subclass DynamicConfigPageMixin.

lookup_attrs: Sequence[str] = ('page_id',)[source]

A list of attributes that items can be looked up by.

Type

list of str

default_errors: Dict[str, str] = {'already_registered': 'Could not register page %(item)s: This page is already registered.', 'attribute_registered': 'Could not register page %(item)s: Another page (%(duplicate)s) is already registered with %(attr_name)s = %(attr_value)s.', 'form_already_registered': 'Could not register page %(page)s: One of its forms (%(form)s) has already been registered with the %(duplicate)s page.', 'invalid_attribute': '"%(attr_name)s" is not a registered lookup attribute.', 'load_entry_point': 'Could not load entry point %(entry_point)s: %(error)s.', 'missing_attribute': 'Could not register %(item)s: it does not have a "%(attr_name)s" attribute.', 'not_registered': 'No item registered with %(attr_name)s = %(attr_value)s.', 'unregister': 'Failed to unregister unknown account page %(item)s: This page is is not registered.'}[source]

The default error formatting strings.

If subclasses need to provide additional errors that can be overridden, they should copy DEFAULT_ERRORS and set their copy on the subclass as this attribute.

Type

dict

__init__()[source]

Initialize the OrderedRegistry

register(page_class)[source]

Register a configuration page class.

A page ID is considered unique and can only be registered once.

This will also register all form classes on the page. If registration for any form fails, registration for the entire class will fail. In this case, the page will become unregistered, as well as any forms on that page that were successfully registered.

Parameters

page_class (type) – The page class to register, as a subclass of djblets.configforms.pages.ConfigPage.

Raises
unregister(page_class, registered_forms=None)[source]

Unregister a configuration page class.

Parameters
  • page_class (type) – The page class to unregister, as a subclass of djblets.configforms.pages.ConfigPage.

  • registered_forms (list, optional) – The forms that have been successfully registered for the class. This attribute is only used when registration of forms was only partially successful.

Raises

djblets.registries.errors.ItemLookupError – Raised when the specified class or form is not registered.

add_form_to_page(page_class, form_class)[source]

Add a form to the page.

Callers should prefer to use add_form() over this method.

Parameters
Raises
remove_form_from_page(page_class, form_class)[source]

Remove a form from the page.

Callers should prefer to use remove_form() over this method.

Parameters
Raises

djblets.registries.errors.ItemLookupError – Raised if the form was not previously registered.

__annotations__ = {'_by_id': 'Dict[int, RegistryItemType]', '_items': 'Set[RegistryItemType]', '_key_order': 'List[int]', '_populated': 'bool', '_registry': 'Dict[str, Dict[object, RegistryItemType]]', 'already_registered_error_class': 'Type[AlreadyRegisteredError]', 'default_errors': 'Dict[str, str]', 'errors': 'Dict[str, str]', 'item_name': 'Optional[str]', 'lookup_attrs': 'Sequence[str]', 'lookup_error_class': 'Type[ItemLookupError]'}
__parameters__ = ()