angee.resources.entries
Value objects for declared addon resource files and parsed rows.
_ResourceAddon
class _ResourceAddon(Protocol)Addon facts consumed by resource declarations.
name
@property
def name() -> strReturn the full dotted Django app name.
label
@property
def label() -> strReturn the short Django app label.
path
@property
def path() -> strReturn the filesystem path to the addon package root.
resolve_model
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
def resource_manifest_for(
app_config: AppConfig) -> dict[str, tuple[dict[str, Any], ...]]Return normalized resource declarations keyed by tier for one addon.
ResourceEntry
@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
@classmethod
def from_declaration(cls, addon: _ResourceAddon, tier: str,
declaration: ResourceDeclaration) -> ResourceEntryReturn an entry from a resource declaration, resolving its source type.
source
@property
def source() -> strReturn this entry's stable source value (path, URL, …).
key
@property
def key() -> EntryKeyReturn the dependency and exclusion key for this resource entry.
display
@property
def display() -> strReturn an owner-qualified name for diagnostics.
materialize
def materialize() -> PathReturn the local file path, materializing the source once.
read_resource_rows
def read_resource_rows() -> tuple[ResourceRow, ...]Return parsed and normalized rows from this entry.
read_grant_rows
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
def infer_model_label() -> strInfer app.Model from a [NNN_]app.model.ext filename.
EntryGraph
@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
@classmethod
def from_entries(cls, entries: Iterable[ResourceEntry]) -> EntryGraphReturn a graph over entries in their selected order.
ordered
def ordered() -> tuple[ResourceEntry, ...]Return entries in dependency order, preserving independent order.
ResourceRow
@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
@classmethod
def from_record(cls,
entry: ResourceEntry,
record: Mapping[str, Any],
*,
index: int,
fallback_model: str | None = None) -> ResourceRowReturn a normalized row from parsed file data.
dataset_row
@property
def dataset_row() -> dict[str, Any]Return the row as an import-export dataset mapping.
GrantRow
@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
@classmethod
def from_record(cls, entry: ResourceEntry, record: Mapping[str, Any], *,
index: int) -> GrantRowReturn one validated grant row from parsed file data.
GrantGroup
@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
@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
def to_dataset() -> tablib.DatasetReturn this group as a tablib dataset.
ValidationResult
@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
@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
def with_result(result: Result) -> LoadResultReturn this load count plus import-export's native result totals.
loaded
@property
def loaded() -> intReturn the number of created or updated rows.