Skip to content

angee.resources.widgets

Import-export widgets for resolving resource xrefs.

XrefWidgetMixin

python
class XrefWidgetMixin()

Carry the resource ledger model bound by AngeeResource.

ledger_model

Concrete resource ledger model used to resolve xrefs.

addon_aliases

Addon aliases keyed by full addon name and short label.

model

Related model bound by the import-export FK/M2M widget base.

resolve_field_target

python
def resolve_field_target(ref: str) -> models.Model

Resolve one xref to a row assignable to this widget's related field.

resolve_xref returns the concrete row a <addon>.<xref> handle names. A runtime = True materialized child is an MTI subclass that shares its parent's primary key (Organization IS-A Party), so a child xref is a valid value for a foreign key to its MTI parent: accept any instance of the bound target model — including such a descendant, whose shared pk resolves the parent link — and fail fast on a genuinely unrelated type.

XrefForeignKeyWidget

python
class XrefForeignKeyWidget(XrefWidgetMixin, widgets.ForeignKeyWidget)

Resolve <addon>.<xref> foreign keys through the ledger.

clean

python
def clean(value: Any,
          row: Mapping[str, Any] | None = None,
          **kwargs: Any) -> Any

Return the target object or primary key for one xref value.

XrefManyToManyWidget

python
class XrefManyToManyWidget(XrefWidgetMixin, widgets.ManyToManyWidget)

Resolve scalar or list xref values for many-to-many fields.

clean

python
def clean(value: Any,
          row: Mapping[str, Any] | None = None,
          **kwargs: Any) -> list[models.Model]

Return target model objects for every xref in value.

_NativeJSONWidget

python
class _NativeJSONWidget(widgets.JSONWidget)

Accept native YAML/JSON values as already-clean JSON values.

clean

python
def clean(value: Any,
          row: Mapping[str, Any] | None = None,
          **kwargs: Any) -> Any

Return native JSON values unchanged.

resolve_xref

python
def resolve_xref(value: str, ledger_model: type[models.Model] | None,
                 addon_aliases: Mapping[str, str] | None) -> models.Model

Resolve <addon>.<xref> through the resource ledger.

resolve_ledger_xref

python
def resolve_ledger_xref(handle: str) -> models.Model | None

Resolve a <addon>.<xref> handle through the composed resource ledger.

The high-level companion to :func:resolve_xref: it binds the concrete resources.Resource ledger and builds the addon-alias map from the app registry — each installed app's dotted name and short label both resolve to its canonical dotted name, the same alias convention the loader builds per selected addon (:meth:~angee.resources.managers.ResourceQuerySet._addon_aliases). So a demo-seed after_resource_load hook resolves a persona (or any ledger row) by the very xref the grant fixtures use, with a single owner for who a handle names. Returns None for an unresolved or ambiguous handle so the hook can skip gracefully rather than raise.

xref_list

python
def xref_list(value: Any) -> list[str]

Return xref strings from a comma-separated string or sequence.

Released under the AGPL-3.0 License.