id_translation.fetching.types#

Types related to translation fetching.

Module Attributes

FetchOperation

Key operation types for fetching.

Operation

Key operation types for fetchers.

Classes

FetchInstruction(source, placeholders, ...)

Instructions passed from an AbstractFetcher to an implementation.

IdsToFetch(source, ids)

A source and the IDs to fetch from it.

PartialCacheHit(translations[, covered])

Partial result of CacheAccess.load(): cached rows plus the IDs the cache vouches for.

class FetchInstruction(source, placeholders, required, placeholder_attributes, ids, task_id, enable_uuid_heuristics)[source]#

Bases: Generic[SourceType, IdType]

Instructions passed from an AbstractFetcher to an implementation.

enable_uuid_heuristics#

Improves matching when UUID-like IDs are in use.

Implementations which have no UUID heuristics may silently ignore this flag.

property fetch_all#

If True, retrieve all available data.

ids#

Unique IDs to fetch translations for.

placeholder_attributes#

See Format.placeholder_attributes for details.

placeholders#

All desired placeholders in preferred order.

required#

Placeholders that must be included in the response.

source#

Where to fetch from.

task_id#

Used for logging purposes.

FetchOperation#

Key operation types for fetching.

alias of Literal[‘FETCH’, ‘FETCH_ALL’]

class IdsToFetch(source, ids)[source]#

Bases: Generic[SourceType, IdType]

A source and the IDs to fetch from it.

ids#

Unique IDs to fetch translations for.

source#

Where to fetch from.

Operation = typing.Literal['INITIALIZE_SOURCES'] | typing.Literal['FETCH', 'FETCH_ALL']#

Key operation types for fetchers.

class PartialCacheHit(translations, covered=None)[source]#

Bases: Generic[SourceType, IdType]

Partial result of CacheAccess.load(): cached rows plus the IDs the cache vouches for.

Attention

Not supported for FetchInstruction.fetch_all instructions.

Returning this – instead of a full PlaceholderTranslations (complete hit) or None (miss) – tells the AbstractFetcher to fetch only the missing IDs and merge them with translations.

covered = None#

Requested IDs the cache is satisfying.

Defaults to the IDs present in translations (extracted by the fetcher); set this only to additionally vouch for IDs that have no row, e.g. known-missing IDs for negative caching.

property placeholders#

Layout to fetch the missing IDs with; a thin alias of translations.placeholders.

Hint

Use the CacheAccess.parent to access e.g. available placeholders.

The fetcher fetches the complement using at least these placeholders, so a cache keeps its stored layout cohesive (avoiding a per-request layout split) simply by returning that layout here – even when translations has no rows.

translations#

Cached PlaceholderTranslations, scoped to the requested IDs.

May be empty (length of PlaceholderTranslations.records is 0) to enforce layout; see placeholders.