Use the built-in Python module “vtcmodel” to retrieve information about the Vertec data model behind the business objects.
The Vertec Python Module vtcmodel allows to query information about the data model behind the business objects. It is also available in Resctict Scripting mode and includes the method:
Gets the information of the given Vertec object or class and returns a Typeinfo Python object.
The Typeinfo object has the following properties:
| Member / Function | Description |
|---|---|
name |
Returns the class name in the current Vertec model language |
defaultname |
Returns the default class name in the model |
persistent |
Specifies whether objects of this class are saved and stored in the database. |
members |
List of all members of this class |
memberbyname(name: String): member |
Returns the specified member as a |
The Member object has the following properties:
Members can be both attributes (normal fields) and associations (links to other objects). Depending on whether it is an attribute or an association, the Member object has slightly different properties. This is noted in the respective row.
| Characteristics | Description | Attribute | Association |
|---|---|---|---|
allownull |
Specifies whether the member may be empty (NULL) | x | x |
classinfo |
The class to which the member belongs (Typeinfo as above) |
x | x |
column name |
Column name of the member in the database (persistent members only) | x | x |
defaultname |
Default member name in model | x | x |
derived |
Indicates whether the attribute is a derived attribute. | x | |
isattribute |
Indicates whether the member is an attribute. | x | x |
isindirect |
Specifies whether the association is part of a multilink (m:n), in which case there is a link object (linkclass). | x | |
ismultirole |
Indicates whether the member is the multi-end of a link, so it can also be used as a list. | x | x |
isrole |
Specifies whether the member is a link role, i.e. the member is an association. | x | x |
issinglerole |
Indicates whether the member is the single end of a link. | x | x |
length |
Specifies the maximum allowed length of the attribute. This is relevant for strings. | x | |
linkclass |
The name of the link class if it is a multilink (isindirect). | x | |
name |
Name of the member in the current model language | x | x |
ordered |
Indicates whether it is a sorted association. | x | |
otherend |
The other side of the association, also gives a Member Object back. |
x | |
persistent |
Specifies whether the member is saved in the database. | x | x |
valuetype |
Data type of the attribute. Possible values are:
|
x |
Some of these properties can also be seen in the Vertec Model Browser on the right hand side when you select a member in the list.
The example script can be run on a project in the Vertec Script Editor.
import vtcmodel typeinfo = vtcmodel.gettypeinfo(argobject) # argobject is a project print("Class name (actual model language): {}".format(typeinfo.name)) # Projekt/Project print("Class name (model): {}".format(typeinfo.defaultname)) # Project print("Stored in DB: {}".format(typeinfo.persistent)) # True members = typeinfo.members # List of all "member" objects member = typeinfo.memberbyname("Active") # Info about member "active" print("Member name (actual model language): {}".format(member.name)) # aktiv/active print("Member name (model): {}".format(member.defaultname)) # active print("Value type: {}".format(member.valuetype)) # Boolean (string) print("Stored in DB: {}".format(member.persistent)) # True print("Derived: {}".format(member.derived)) # False print("Null/Empty allowed: {}".format(member.allownull)) # False print("Is attribute: {}".format(member.isattribute)) # True print("Is Linkrole / Association: {}".format(member.isrole)) # False print("Is single role: {}".format(member.issinglerole)) # False print("Is multi role: {}".format(member.ismultirole)) # False print("Column name in DB: {}".format(member.columnname)) # Active print("Length: {}".format(member.length)) # 255, only relevant on Strings print("Backlink on 'Project' ClassInfo: {}".format(member.classinfo.name)) # Projekt/Project role_member = typeinfo.memberbyname("Customer") # Info about the association to the customer # Attributes like above, except for "valuetype" and "derived", instead: print("Link class: {}".format(role_member.linkclass)) # None print("Ordered: {}".format(role_member.ordered)) # True print("Name of the member on the other side: {}".format(role_member.otherend.name)) # projekte/projects