Session
IncludesSession and SessionBuilder classes.
The SessionBuilder class is used to specify Granta MI connection information, and returns a Session
object once the connection to the server is complete.
The Session object acts as the root object from which most other Streamlined API objects are spawned, and is
typically used to:
- Get
Databaseobjects, which can be used to accessTableandRecordobjects. - Perform text searches across all records on the server with the
Session.search_for_records_by_text()andSession.search_for_records_by_name()methods. - Write changes to the Granta MI server with the
Session.update()andSession.update_links()methods. - Perform bulk activities across multiple records, optionally in different databases and tables.
Database and Table
Includes theDatabase and Table classes.
The Database class represents Granta MI databases. Database objects are typically obtained by using
the Session.get_db() method.
The Table class represents Granta MI tables. Table objects are typically obtained by using the
Database.get_table() method.
Database and Table objects are used to:
- Get
Recordobjects from aTableobject based on their location in the record tree. - Get
Recordobjects from aDatabaseorTableobject by text, record name, or attribute value searching. - Access schema information, such as
mi_meta_classes.TableLayoutandmi_meta_classes.LinkGroupDetailsobjects.
Record
Includes theRecord class.
The Record class represents Granta MI records.
Record objects are used to:
- Access and modify data stored in attributes via the
Record.attributesdictionary. - Access and modify properties of the record, such as
Record.nameandRecord.color - Access links via the
Record.linksdictionary, and modify them with theRecord.set_links()method. - Copy and move the record with the
Record.copy_to()andRecord.move_to()methods.
Attribute definitions
Includes thePseudoAttributeDefinition and AttributeDefinition class, and all
AttributeDefinition sub-classes. The AttributeDefinition class is subclassed according to the
hierarchy described below:
AttributeDefinition(no objects are direct instances of this type)AttributeDefinitionDateAttributeDefinitionDiscreteAttributeDefinitionFileAttributeDefinitionHyperlinkAttributeDefinitionIntegerAttributeDefinitionLogicalAttributeDefinitionLongTextAttributeDefinitionPictureAttributeDefinitionRangeAttributeDefinitionShortTextAttributeDefinitionTabularAttributeDefinitionMultiValue(no objects are direct instances of this type)AttributeDefinitionUnsupported(no objects are direct instances of this type)
AttributeDefinition classes represent the definition of an attribute on a Granta MI server, as opposed
to an instance of an attribute which contains data. They are not associated with a particular record, only with the
table that they are defined in.
AttributeDefinition objects are used to access the attribute name, attribute unit, and additional schema-level
configuration based on the type of the attribute.
PseudoAttributeDefinition objects can generally be used in place of AttributeDefinition objects to
search or export pseudo-attributes.
Attribute values
Includes theAttributeValue class and all sub-classes. The
AttributeValue class is subclassed according to the hierarchy
described below:
AttributeValue: Base class for all attributesAttributeBinary: Parent class for binary attributes (no objects are direct instances of this type)AttributePicture: Picture dataAttributeFile: File data
AttributeDate: Datetime dataAttributeDiscrete: Parent class for discrete attributes (no objects are direct instances of this type)AttributeDiscreteSingle: Single-valued discrete dataAttributeDiscreteMulti: Multi-valued discrete data
AttributeFunctionalSeriesPoint: Float functional series dataAttributeFunctionalSeriesRange: Ranged float functional series dataAttributeFunctionalGridPoint: Float functional gridded dataAttributeFunctionalGridRange: Ranged float functional gridded dataAttributeHyperlink: Hyperlink dataAttributeInteger: Integer dataAttributeLogical: Logical dataAttributePoint: Parent class for point attributes (no objects are direct instances of this type)AttributePointSingle: Single-valued point dataAttributePointMulti: Multi-valued point data
AttributeRange: Range dataAttributeTabular: Tabular dataAttributeShortText: Short text dataAttributeLongText: Long text dataAttributeUnsupported: Unsupported dataPseudoAttributeValue: Pseudo-attribute value class covering all pseudo-attribute types
AttributeValue classes are analogous to the attribute
definition classes, but represent attribute values. They are associated with both the table and record that they
relate to. In addition to being able to access the attribute name and attribute unit, they can be used to access data
values (if the attribute is populated for the associated record).
Schema and supporting items
Includes:- The Schema section. Includes classes used to describe aspects of a database schema.
- The Parameters section. Includes classes used to describe parameters at all levels of the Granta MI object hierarchy.
- The Item history section. Includes classes used to describe revision information of items within a Granta MI database.
- The
SearchCriterionclass. Used to specify search criteria when searching for records by pseudo-attribute value.
AttributeValue classes, but
are not directly associated with a record.
- Media attribute values: File and picture attribute values.
- Numeric attribute values: Multi-valued point attributes and precision information.
- Functional attribute values: Float functional series and float functional grid attribute values.
Tabular attribute value items
Tabular rows
A tabular attribute consists of zero or more rows, each represented by aTabularRow object. This provides access to individual cells, either as a tuple via
the cells property, or by using the
cells_by_column property as a mapping from column names to cell values.
Tabular cells
Cells within a tabular row are represented by specific cell value classes, depending on the type of data stored in the cell. These classes include:- The
ShortTextValueclass, which describes a short text cell, and includes the text value. - The
LongTextValueclass, which describes a long text cell, and includes the text value. - The
LogicalValueclass, which describes a logical cell, and includes the boolean value. - The
IntegerValueclass, which describes an integer cell, and includes the integer value. - The
DateValueclass, which describes a date cell, and includes the date value. - The
PictureValueclass, which describes a binary data cell, and includes the binary data, URL, and MIME file type. This class also enables saving the picture to a file. - The
FileValueclass, which describes a file cell, and includes the binary data, URL, MIME file type, file name, and description. This class also enables saving the file. - The
PointValueclass, which describes a Point cell, and includes the attribute’s value and associated unit. Note that tabular cells can only contain a single point value, and are not associated with parameters. - The
RangeValueclass, which describes a Range cell, and includes the value, inclusivity, and associated unit. - The
DiscreteValueclass, which describes a Discrete cell, and includes the value and the order. - The
HyperlinkValueclass, which describes a Hyperlink cell, and includes URL, target, and description.
- The
LocalShortTextValueclass is a mutable short text cell which allows local cell data to be set. - The
LocalLongTextValueclass is a mutable long text cell which allows local cell data to be set. - The
LocalLogicalValueclass is a mutable logical cell which allows local cell data to be set. - The
LocalIntegerValueclass is a mutable integer cell which allows local cell data to be set. - The
LocalDateValueclass is a mutable date cell which allows local cell data to be set. - The
LocalPictureValueclass is a mutable binary data cell which allows local cell data to be set and includes methods for loading binary data from files. - The
LocalFileValueclass is a mutable file cell which allows local cell data to be set and includes methods for loading file data with file name and description properties. - The
LocalPointValueclass exposes thedefault_unitproperty, which returns the default unit for the point value as defined for the column in the attribute definition. - The
LocalRangeValueclass exposes thedefault_unitproperty, which returns the default unit for the range value as defined for the column in the attribute definition. - The
LocalDiscreteValueclass exposes thepossible_discrete_valuesproperty, which returns the possible discrete values for the column in the attribute definition. - The
LocalHyperlinkValueexposes no additional properties.
UnsupportedType objects.
As an alternative, linked records for each row can be accessed AttributeTabular.linked_records and the
functional data can be exported for these records.
Destructive editing
Since v5.0, Scripting Toolkit will always try to update tabular attribute values via an update operation, by only updating the modified cells and leaving the tabular rows and unmodified cells in place. However, there are some tabular data modifications which cannot be performed as an update operation, and instead the tabular value must be completely re-created. This is referred to as ‘destructive editing’. Destructive editing should be avoided because:- This can be slow for attributes with File or Picture attributes, especially if many rows are present.
- Users of Data Updater will face conflicts when applying subsequent updates.
AttributeTabular.swap_rows()TabularRow.set_linking_value()for an exported row
ValueError to inform the user that a destructive action
has been performed. To allow the destructive action, first call the method
enable_destructive_editing(). See the API guide for more details,
including additional considerations when performing destructive editing with binary data.
Destructive editing may also be forced for a tabular attribute by calling force_destructive_editing() before
importing the data.