gavo.dm.dmrd module¶
Writing annotations in RDs.
This module provides the glue between annotations (typically in SIL) and the rest of the RDs. It provides the ResAnnotation struct, which contains the SIL, and the makeAttributeAnnotation function that is a factory for attribute annotations.
- class gavo.dm.dmrd.DataModelRoles(parent, **kwargs)[source]¶
Bases:
Structure
an annotation of a table in terms of data models.
The content of this element is a Simple Instance Language clause.
- attrSeq = [<gavo.base.parsecontext.IdAttribute object>, <gavo.base.structure.DataContent object>]¶
- completedCallbacks = []¶
- copy(newParent, ctx)[source]¶
returns a deep copy of self, reparented to parent.
This is a shallow wrapper around change, present for backward compatibility.
- managedAttrs = {'content_': <gavo.base.structure.DataContent object>, 'id': <gavo.base.parsecontext.IdAttribute object>}¶
- name_ = 'dm'¶
- class gavo.dm.dmrd.DataModelRolesAttribute[source]¶
Bases:
StructListAttribute
an attribute allowing data model annotation using SIL.
It will also give an annotations attribute on the instance, and a getAnnotationsOfType method letting you pull out a specific annotation.
For situation where an existing annotation should be copied from annotations coming in through columns and/or params, the attribute also gives an updateAnnotationFromChildren method. It will do nothing if some annotation already exists.
- class gavo.dm.dmrd.SynthesizedRoles(parent, **kwargs)[source]¶
Bases:
Structure
DM annotation copied and adapted to a new table.
This is a stand-in for DataModelRoles in tables not parsed from XMLs. Their DM structure is defined through references the columns and params make to the annotations their originals had.
These have no attributes but just arrange for the new annotations to be generated.
- attrSeq = [<gavo.base.parsecontext.IdAttribute object>]¶
- completedCallbacks = []¶
- managedAttrs = {'id': <gavo.base.parsecontext.IdAttribute object>}¶
- name_ = '_synthesizedRoles'¶
- gavo.dm.dmrd.buildAdhocSTC(table, vals)[source]¶
builds a modern adhoc STC annotation in table based on a mapping of attribute paths to annotation targets in vals.
This is only necessary as long as we want to support <stc> specs. The keys here are, in effect defined in rscdef.tabledef; see _utypeToModern.
- gavo.dm.dmrd.getAnnotationMaker(container)[source]¶
wraps makeAttributeAnnotationMaker such that names are resolved within container.
- gavo.dm.dmrd.makeAttributeAnnotation(container, instance, attName, attValue)[source]¶
returns a typed annotation for attValue within container.
When attValue is a literal, this is largely trivial. If it’s a reference, this figures out what it points to and creates an annotation of the appropriate type (e.g., ColumnAnnotation, ParamAnnotation, etc).
container in current DaCHS should be a TableDef or something similar; this function expects at least a getByName function and an rd attribute.
instance is the root of the current annotation. Complex objects should keep a (weak) reference to that. We don’t have parent links in our dm trees, and without a reference to the root there’s no way we can go “up”.
This is usually used as a callback from within sil.getAnnotation and expects Atom and Reference instances as used there.