Skip to content

angee.resources.entries ​

Value objects for declared addon resource files and parsed rows.

_ResourceAddon ​

python
class _ResourceAddon(Protocol)

Addon facts consumed by resource declarations.

name ​

python
@property
def name() -> str

Return the full dotted Django app name.

label ​

python
@property
def label() -> str

Return the short Django app label.

path ​

python
@property
def path() -> str

Return the filesystem path to the addon package root.

resolve_model ​

python
def resolve_model(label: str) -> type[models.Model]

Return the model class named by an app_label.ModelName label.

ResourceDeclaration ​

One normalized resource entry declaration.

AdoptDeclaration ​

Normalized resource adoption declaration.

EntryKey ​

Dependency graph key identifying one resource entry by addon and source.

RESERVED_ROW_KEYS ​

Row keys interpreted by the resource loader rather than model fields.

ROW_KIND ​

Default entry kind: rows imported into a Django model through the ledger.

GRANT_KIND ​

Entry kind whose rows the loader materializes into REBAC relationship tuples.

ENTRY_KINDS ​

Every resource entry kind the loader knows how to materialize.

GRANT_ROW_KEYS ​

The three fields one declarative grant row must carry, in tuple direction.

TEXT_FORMATS ​

Supported text resource formats keyed by file suffix.

STRUCTURED_FORMATS ​

Text formats that can carry _meta and rows envelopes.

resource_manifest_for ​

python
def resource_manifest_for(
        app_config: AppConfig) -> dict[str, tuple[dict[str, Any], ...]]

Return normalized resource declarations keyed by tier for one addon.

ResourceEntry ​

python
@dataclass(slots=True)
class ResourceEntry()

One local or remote resource file declared by an addon.

addon ​

Addon that owns this resource declaration.

tier ​

Normalized resource tier value.

source_key ​

Registered source key (path for a local file; url once integrate adds it).

source_value ​

The source's stored value — an addon-relative path, a URL, etc.

model ​

Optional fallback model label for every row in the file.

kind ​

Materialization kind: rows (model rows) or grants (REBAC tuples).

encoding ​

Text encoding used when reading the materialized file.

depends_on ​

Resource source keys that must load before this entry.

adopt ​

Unique field(s) used for adoption; True infers one unique field.

publish ​

Whether loaded rows should be published by a target-model resource hook.

from_declaration ​

python
@classmethod
def from_declaration(cls, addon: _ResourceAddon, tier: str,
                     declaration: ResourceDeclaration) -> ResourceEntry

Return an entry from a resource declaration, resolving its source type.

source ​

python
@property
def source() -> str

Return this entry's stable source value (path, URL, …).

key ​

python
@property
def key() -> EntryKey

Return the dependency and exclusion key for this resource entry.

display ​

python
@property
def display() -> str

Return an owner-qualified name for diagnostics.

materialize ​

python
def materialize() -> Path

Return the local file path, materializing the source once.

read_resource_rows ​

python
def read_resource_rows() -> tuple[ResourceRow, ...]

Return parsed and normalized rows from this entry.

read_grant_rows ​

python
def read_grant_rows() -> tuple[GrantRow, ...]

Return parsed grant rows for a kind = "grants" entry.

A grant file is a flat list of {resource, relation, subject} rows; it declares no model (the loader materializes tuples, not model rows), so a model in the entry or file metadata is a declaration error.

infer_model_label ​

python
def infer_model_label() -> str

Infer app.Model from a [NNN_]app.model.ext filename.

EntryGraph ​

python
@dataclass(frozen=True, slots=True)
class EntryGraph()

Dependency graph for a selected set of resource entries.

entries ​

Entries selected for one resource operation.

from_entries ​

python
@classmethod
def from_entries(cls, entries: Iterable[ResourceEntry]) -> EntryGraph

Return a graph over entries in their selected order.

ordered ​

python
def ordered() -> tuple[ResourceEntry, ...]

Return entries in dependency order, preserving independent order.

ResourceRow ​

python
@dataclass(slots=True)
class ResourceRow()

One normalized resource row.

entry ​

Entry that contributed this row.

model_label ​

Django model label targeted by this row.

xref ​

Addon-local external row key.

values ​

Model field values to import.

from_record ​

python
@classmethod
def from_record(cls,
                entry: ResourceEntry,
                record: Mapping[str, Any],
                *,
                index: int,
                fallback_model: str | None = None) -> ResourceRow

Return a normalized row from parsed file data.

dataset_row ​

python
@property
def dataset_row() -> dict[str, Any]

Return the row as an import-export dataset mapping.

GrantRow ​

python
@dataclass(slots=True)
class GrantRow()

One declarative REBAC grant row, in resource <- relation <- subject direction.

entry ​

Entry that contributed this grant row.

resource ​

The grant resource: a <ns>/type:<const-id> literal or a row xref.

relation ​

The relation granted on the resource (e.g. member, direct_member).

subject ​

The subject granted: a user/row xref, a <ns>/role:<id>`member``` literal, or *``.

index ​

1-based position of this row within its source file, for diagnostics.

from_record ​

python
@classmethod
def from_record(cls, entry: ResourceEntry, record: Mapping[str, Any], *,
                index: int) -> GrantRow

Return one validated grant row from parsed file data.

GrantGroup ​

python
@dataclass(slots=True)
class GrantGroup()

Grant rows from one kind = "grants" entry.

entry ​

Resource entry that supplied the grant rows.

rows ​

Grant rows the loader materializes into REBAC relationship tuples.

ResourceGroup ​

python
@dataclass(slots=True)
class ResourceGroup()

Rows from one entry that target one model.

entry ​

Resource entry that supplied the rows.

model ​

Django model imported by this group.

rows ​

Rows loaded into the target model.

to_dataset ​

python
def to_dataset() -> tablib.Dataset

Return this group as a tablib dataset.

ValidationResult ​

python
@dataclass(slots=True)
class ValidationResult()

Counts returned by resource validation.

checked_files ​

Number of resource files checked.

checked_rows ​

Number of resource rows checked.

LoadResult ​

python
@dataclass(slots=True)
class LoadResult()

Counts returned by a resource load.

created ​

Rows created during the load.

updated ​

Rows updated during the load.

skipped ​

Rows skipped because the ledger already matched.

with_result ​

python
def with_result(result: Result) -> LoadResult

Return this load count plus import-export's native result totals.

loaded ​

python
@property
def loaded() -> int

Return the number of created or updated rows.

Released under the AGPL-3.0 License.