angee.base.impl
Framework base for registry-resolved implementation classes.
An :class:~angee.base.fields.ImplClassField column selects one of these by key. Beyond the behaviour its domain needs, an impl carries shared metadata and defaults — the field values the owning row materialises when the impl is chosen. Defaults merge along the MRO, so refinements inherit their base's defaults and override only what differs. Abstract bases leave key blank and stay out of the registry; concrete leaves register a key and are pickable.
ImplBase
class ImplBase()Base for an implementation selectable by an ImplClassField key.
Subclasses declare class-level key/label/icon/category and a defaults mapping of model-field values to seed. Behaviour lives on the domain subclass (e.g. IntegrationImpl, OAuthProviderType).
effective_defaults
@classmethod
def effective_defaults(cls) -> dict[str, Any]Return this impl's defaults merged along the MRO (base → derived; derived wins).
Dict-valued defaults (e.g. a config preset) merge one level deep, so a refinement adds keys to its base's dict default instead of replacing it; scalar values are overridden outright.
display_label
@classmethod
def display_label(cls) -> strReturn this impl's own label, falling back to a title-cased key.
label is each impl's name, not a domain trait: a refinement that omits it reads from its key, never the base's label. icon/category inherit normally.
choice
@classmethod
def choice(cls) -> dict[str, Any]Return this impl's pickable choice metadata for forms (key/label/icon/category/defaults).
materialize
@classmethod
def materialize(cls,
instance: models.Model,
*,
provided: frozenset[str] = frozenset()) -> NoneSeed instance's fields from this impl's effective defaults on create.
Seeds only fields the caller did not supply (provided = the explicitly passed field names) — the reliable "unset" signal, so a boolean default such as login_enabled=True lands when omitted yet an explicit False the caller passed is never overwritten. A string foreign-key default resolves against the related model's slug (a missing target leaves the FK unset); mutable defaults are deep-copied so rows never alias the class-level dict.
ImplDefaultsMixin
class ImplDefaultsMixin(models.Model)Materialise impl defaults on create for every ImplClassField on the model.
The backend safety net behind the form-level prefill: a row created without a form (API, resource seed) still gets the chosen impl's defaults — for the fields the caller did not supply. Form-created rows pass their (possibly edited) values, so the impl never overrides them, even when a value equals the model default.
Meta
class Meta()Abstract: contributes the create-time default seeding only.
impl_key_for
@classmethod
def impl_key_for(cls,
field_name: str,
value: Any,
*,
default: str | None = None) -> strReturn the canonical registry key for one ImplClassField value.
__init__
def __init__(*args: Any, **kwargs: Any) -> NoneRecord the caller-supplied field names so create-time seeding skips them.
save
def save(*args: Any, **kwargs: Any) -> NoneSeed impl defaults for unsupplied fields on first insert, then persist.
set_impl_key
def set_impl_key(field_name: str,
value: Any,
*,
default: str | None = None) -> boolAssign an impl key and return whether the stored key changed.
materialize_impl_defaults
def materialize_impl_defaults(
field_name: str, *, provided: frozenset[str] = frozenset()) -> NoneApply the selected impl's defaults for one impl field.