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 at is a factory for attribute annotations.

class, **kwargs)[source]

Bases: gavo.base.structure.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.

Do not call this while the RD is still being built, as dm elements may contain forward references, and these might not yet be available during the parse.


Bases: gavo.base.complexattrs.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: gavo.base.structure.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][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.