djblets.configforms.registry¶
A registry for configuration forms and pages.
- class ConfigPageRegistry[source]¶
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
.- 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
djblets.registries.errors.AlreadyRegisteredError – Raised if the page has already been registered.
djblets.registries.errors.RegistrationError – Raised if the page shares an attribute with an already registered page or if any of its forms share an attribute with an already registered form.
- 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
page_class (type) – The page to add the form to, as a subclass of
djblets.configforms.pages.ConfigPage
.form_class (type) – The form to add to the page, as a subclass of
djblets.configforms.page.ConfigPage
.
- Raises
djblets.registries.errors.AlreadyRegisteredError – Raised if the form has already been registered.
djblets.registries.errors.RegistrationError – Raised if the form shares an attribute with an already registered form.
- 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
page_class (type) – The page to remove the form from, as a subclass of
djblets.configforms.pages.ConfigPage
.form_class (type) – The form to remove from the page, as a subclass of
djblets.configforms.forms.ConfigPageForm
.
- Raises
djblets.registries.errors.ItemLookupError – Raised if the form was not previously registered.