co3.collector module¶
Defines the Collector base class.
This module is the critical “middleware” connecting the primitive object definitions and their representations in the database. It operates with full knowledge of how both are defined, and abstracts away both the prep work for DB insertions as well as updates trickling down the primitive hierarchy.
The src
format target is re-used for both canonical tables/primitives, as well as
<prim>_conversion_matter
tables in tables/conversions under the src
format. The
latter is meant to extend those attributes that are format-specific (i.e., would change
when, say, converting to html5
), and thus need to be broken across the format
dimension.
Note
Despite the structure of the database module, this class does not currently inherit from a super class in localsys.db (like the accessors and managers, for instance). This will likely ultimately be the model that’s embraced, but until FTS (or other groups) need a collector, this will be remain an independent class. It is, however, named like a concrete subclass, taking on the “Core” prefix.
- class co3.collector.Collector(schema)[source]¶
Bases:
Generic
- add_insert(component, insert_data, receipts=None)[source]¶
- Parameters:
component (
TypeVar
(C
, bound=Component
)) – Component from registered schemainsert_data (
dict
) – dict with (possibly raw/incomplete) insert datareceipts (
list
|None
) – optional list to which generated receipt should be appended. Accommodates the common receipt list aggregation pattern.
- collect_inserts(receipts=None)[source]¶
Collect insert-ready dictionaries for the core primitive schema. This method is effectively a light wrapper around the File and Note-based collection logic elsewhere in the class.
The overall collection scheme embraces a session-like sequential update model to an internal insert tracker. The sequence of insert methods is ordered according to the schema hierarchy, and higher level inserts dictate the scope for lower level inserts (all methods check and populate the same
inserts
dictionary). Calling this method flushes any existing inserts, ensuring a re-scan takes place across calls (or “sessions”).- Parameters:
skip_updated – whether to ignore primitives with existing up-to-date database entries
- Returns:
Table name-indexed dictionary of insert lists (of column name-indexed dicts)
- property inserts¶