Package gavo :: Package utils :: Module serializers :: Class AnnotatedColumn
[frames] | no frames]

Class AnnotatedColumn

source code

object --+
         |
        AnnotatedColumn

A collection of annotations for a column.

ColumnAnntotations are constructed with columns and retain a reference to them ("original").

In addition, they provide a getitem/setitem interface to a dictionary that contains "digested" information on the column. This dictionary serves as an accumulator for information useful during the serialization process.

The main reason for this class is that Columns are supposed to be immutable; thus, any ephemeral information needs to be kept in a different place. In particular, the mapper factories receive such annotations.

As a special service to coerce internal tables to external standards, you can pass a votCast dictionary to AnnotatedColumn. Give any key/value pairs in there to override what AnnotatedColumn guesses or infers. This is used to force the sometimes a bit funky SCS/SIAP types to standard values.

The castMapperFactory enabled by default checks for the presence of a castFunction in an AnnotatedColumn. If it is there, it will be used for mapping the values, so this is another thing you can have in votCast.

The SerManager tries to obtain votCasts from a such-named attribute on the table passed in.

Though of course clients can access original, the mapping facets should only be accessed through getitem/setitem since they may be updated wrt what is in original.

Attributes available via the setitem/getitem interface include:

Instance Methods
 
__init__(self, column, votCast=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__getitem__(self, key) source code
 
__setitem__(self, key, value) source code
 
__contains__(self, key) source code
 
get(self, key, default=None) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, column, votCast=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)