fairdm.contrib.plugins.checks#
Registration-time validation that refuses a plugin registration that cannot work.
Validation runs in the decorator rather than in Django’s check framework, because checks only run from management commands and would never fire on a production boot.
Module Contents#
Functions#
Require at least one model and that each is a Django model class. |
|
Require |
|
Require a path segment to be usable in a route. |
|
Require additional views to be plugins that do not collide, nest or claim the plugin’s own address. |
|
List every URL name the plugin will generate. |
|
Require names, segments and generated URL names to be unique for one record type. |
|
Run every check possible when a plugin is registered against one record type. |
API#
- exception PluginRegistrationError[source]#
Bases:
django.core.exceptions.ImproperlyConfiguredA plugin registration that cannot work.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- validate_models(plugin_class: type[fairdm.contrib.plugins.base.Plugin], models: tuple[Any, ...]) None[source]#
Require at least one model and that each is a Django model class.
Refusal raises
PluginRegistrationError.Args: plugin_class: The plugin being registered. models: The values given to the decorator.
- validate_check(plugin_class: type[fairdm.contrib.plugins.base.Plugin], model: Any) None[source]#
Require
checkto be a bool or a callable the access decision can evaluate.A
classmethodis refused because it is truthy but not callable, so it would permit every request.A failing check raises
PluginRegistrationError.Args: plugin_class: The plugin being registered. model: The record type it is registered against.
- validate_segment(plugin_class: type[fairdm.contrib.plugins.base.Plugin], model: Any, segment: str) None[source]#
Require a path segment to be usable in a route.
A segment Django rejects raises
PluginRegistrationError.Args: plugin_class: The plugin being registered. model: The record type it is registered against. segment: The URL path segment.
- validate_extra_views(plugin_class: type[fairdm.contrib.plugins.base.Plugin], model: Any) None[source]#
Require additional views to be plugins that do not collide, nest or claim the plugin’s own address.
A violation raises
PluginRegistrationError.Args: plugin_class: The plugin being registered. model: The record type it is registered against.
- url_names_for(plugin_class: type[fairdm.contrib.plugins.base.Plugin]) list[str][source]#
List every URL name the plugin will generate.
Args: plugin_class: The plugin.
Returns: The plugin’s own name followed by one name per additional view.
- validate_against_existing(plugin_class: type[fairdm.contrib.plugins.base.Plugin], model: Any, existing: list[tuple[type[fairdm.contrib.plugins.base.Plugin], dict]]) None[source]#
Require names, segments and generated URL names to be unique for one record type.
A clash raises
PluginRegistrationError.Args: plugin_class: The plugin being registered. model: The record type it is registered against. existing: The
(plugin class, options)entries already registered for it.
- validate_registration(plugin_class: type[fairdm.contrib.plugins.base.Plugin], model: Any, existing: list[tuple[type[fairdm.contrib.plugins.base.Plugin], dict]]) None[source]#
Run every check possible when a plugin is registered against one record type.
A registration that cannot work raises
PluginRegistrationError.Args: plugin_class: The plugin being registered. model: The record type it is registered against. existing: The
(plugin class, options)entries already registered for it.