Skip to content
Reference of plugins_api 2.0.1, an older major version. See this page for plugins_api 3.0.0.

plugins_api.utils.level_from_plugin

Functions

NameDescription
resolve_field_level_by_plugin_slugResolve the most restrictive level of a plugin field by scanning all MetadataObjectTypes.
resolve_field_level_in_metadata_objectResolve the level of a plugin field within a specific MetadataObjectType.

resolve_field_level_by_plugin_slugfunction#

def resolve_field_level_by_plugin_slug(field_slug: str, source: str) -> str | None

Resolve the most restrictive level of a plugin field by scanning all MetadataObjectTypes.

Useful when only the plugin slug is available (e.g. from a serializer context or a DB source name), without a direct reference to the plugin class or a specific metadata object instance.

The most restrictive level wins across all object types: mandatory (0) > recommended (1) > optional (2).

Parameters

NameTypeDescription
field_slugstrThe slug of the plugin field to look up.
sourcestrThe source plugin that owns the field.

Returns

str or None
The most restrictive level ("mandatory", "recommended", or "optional") across all MetadataObjectTypes, or None if the field is not declared in any of them.

resolve_field_level_in_metadata_objectfunction#

def resolve_field_level_in_metadata_object(plugin_class, metadata_object, field_slug: str, metadata_object_types: dict | None = None) -> str | None

Resolve the level of a plugin field within a specific MetadataObjectType.

Useful in contexts where both the plugin class and the metadata object are already available (e.g. during submission validation or promotion), avoiding a full scan across all object types.

Parameters

NameTypeDescription
plugin_classtypeThe plugin class (not an instance) returned by get_plugin_class().
metadata_objectSubmissionMetadataObjectThe metadata object whose type is used to look up the correct MetadataObjectType on the plugin.
field_slugstrThe slug of the plugin field to look up.

Returns

str or None
The level ("mandatory", "recommended", or "optional") of the field within the matching MetadataObjectType, or None if the object type is not found on the plugin or the field is not declared in it.