cadrumo.domain.calculations.registry.export_field_casilla module

The casilla an export layout field resolves to, and the back-references that follow from it.

A casilla’s export_refs answer “which export fields carry me”. The layout already answers the converse for every field, so the casilla side is derived from it here rather than declared a second time: an edition’s layout owns the edge, and a field moved to another casilla moves its back-reference with it.

A field resolves to a casilla along one of two paths:

  • its own endpoint, endpoint_casilla_id, which covers a casilla_id and a numbered projection_ref;

  • the record row mapping, for a binding field in a repeated record: the binding’s row-set row_field names a slot, and the record’s row_field_casilla_ids names the casilla that slot belongs to.

A binding_record row template contributes no casilla edge. Declaring binding_record makes the export derivation take the record’s field positions from its bindings’ export selectors, so the record’s rows are templates the derivation fills, and neither the casilla field that templates a mapped slot nor a binding field in that record is an edge. A record whose field positions come from the official record design uses row_field_casilla_ids only to say which box each field fills; those rows are real edges and keep their back-references. Declaring binding_record on such a record would add a second source of field positions beside the official design, so the two record shapes are deliberately distinct.

layout_fields_in_emission_order(layout)[source]

Return every field of layout with its record, in the order the layout emits them.

Records are taken by their declared order, records of equal order in declaration order. Within a record, fields are taken by offset, a field declaring no offset ahead of every positioned one, and by field id where two share an offset.

Return type:

tuple[tuple[ExportRecordDefinition, ExportFieldDefinition], ...]

Parameters:

layout (ExportLayoutDefinition)

export_field_casilla_id(record, field, *, bindings)[source]

Return the casilla field of record resolves to, or None when it resolves to none.

bindings maps binding id to its declaration. A binding field naming a binding absent from it, or one that produces no rows, resolves to nothing; reference validation reports the unknown binding.

A binding_record row template contributes no casilla edge: in a record declaring binding_record the field positions come from the bindings’ export selectors, so a casilla field whose casilla is a mapped row slot is the template of that slot and resolves to nothing, and a binding field never takes the row-mapping path. A record without it takes its positions from the official design, and its row mapping names real edges.

Raises:

RegistryValidationError – When a row-producing binding the field names declares a malformed row-set projection.

Return type:

TypeAliasType | None

Parameters:
derive_casilla_export_refs(export_layouts, bindings)[source]

Return every addressed casilla’s export field ids, in the order its layout emits them.

Only casillas some field resolves to appear. The order is part of the value: a casilla’s field ids follow layout_fields_in_emission_order(), record order and then field offset, never the order the declarations happen to be written in.

Raises:

RegistryValidationError – When fields of more than one layout resolve to one casilla. Two layouts each claiming a casilla is a conflict to resolve in the declarations, never a union to take silently.

Return type:

dict[TypeAliasType, tuple[TypeAliasType, ...]]

Parameters: