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, **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.

getAnnotation(roleName, container, instance)[source]
managedAttrs = {'content_': <gavo.base.structure.DataContent object>, 'id': <gavo.base.parsecontext.IdAttribute object>}
name_ = 'dm'

returns a parsed version of the embedded annotation.

The parse really is only run once, but you should only call it once the embedding table is complete, because this needs to resolve table params and columns (and possibly other dm elements).


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.


returns an iterator over (name, method) pairs that should be inserted in the parent class.

class, **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'
synthesizeAnnotations(rd, ctx)[source], 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.[source]

wraps makeAttributeAnnotationMaker such that names are resolved within 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.