The Virtual Brain Project

Table Of Contents

Previous topic

services Package

Next topic

datatype_removers Package

This Page

traits Package

core

class tvb.core.traits.core.DeclarativeMetaType(classname, bases, dict_)[source]

Bases: sqlalchemy.ext.declarative.DeclarativeMeta, tvb.basic.traits.core.MetaType

The DeclarativeMetaType class helps with class creation by automating some of the sqlalchemy code generation. We code for three possibilities:

  • the sql or db keywords are False, no sqlalch used

  • sql or db keywords are True or unset, default sqlalche used

  • sql or db keywords are set with sqlalchemy.Column instances, and

    that is used

If it is desired that no sql/db is used, import traits.core and set TRAITS_CONFIGURATION.use_storage = False. This will have the (hopefully desired) effect that all sql and db keyword args are ignored.

tvb.core.traits.core.compute_table_name(class_name)[source]

Given a class name compute the name of the corresponding SQL table.

db_events

Python Triggers on DB operations.

tvb.core.traits.db_events.attach_db_events()[source]

Attach events to all mapped tables.

tvb.core.traits.db_events.fill_before_insert(_, _ignored, target)[source]

Trigger before storing MappedEntities in DB. Any time, when attaching an entity to the session, make sure meta-data are cascaded on update-able attributes automatically.

tvb.core.traits.db_events.initialize_on_load(target, _)[source]

Call this when any entity is loaded from DB. In case the entity inherits from MappedType, load associated relationships. e.g. TimeSeriesRegion.regions(of type Connectivity) should be populated with:

  • Connectivity instance, and not be a GID, as is default after DB storage.

sql_mapping

A mapping from traited datatypes to sql types.

tvb.core.traits.sql_mapping.get_sql_mapping(input_class)[source]

Look for a SQL-alchemy mapping for the parameter input_class. Also go through all its base classes and check if any of them have a mapping.

types_mapped

tvb.core.traits.types_mapped.Array[source]

traited class Array traits on this class:

dtype ()

default: None
tvb.core.traits.types_mapped.MappedType[source]

Mix-in class combining core Traited mechanics with the db’ed DataType class enabling SQLAlchemy.

traits on this class:

tvb.core.traits.types_mapped.SparseMatrix[source]

traited class SparseMatrix traits on this class:

dtype ()

default: None