Bases: object
The base of the classes representing the entities in the ICAT schema.
Entity is the abstract base for a hierarchy of classes representing the entities in the ICAT schema. It implements the basic behavior of these classes.
Each Entity object is connected to an instance of suds.sudsobject.Object, named instance in the following. Instances are created by Suds based on the ICAT WSDL schema. Entity objects mimic the behavior of the corresponding instance. Attribute accesses are proxied to the instance. A transparent conversion between Entity objects and Suds instances is performed where appropriate.
Name of the entity in the ICAT schema, None for abstract classes.
Attribute or relation names that form a uniqueness constraint.
Attributes stored in the Entity object itself.
Attributes of the entity in the ICAT schema, stored in the instance.
Readonly meta attributes, retrieved from the instance.
Many to one relationships in the ICAT schema.
One to many relationships in the ICAT schema.
Map of alias names for attributes and relationships.
List of attributes used for sorting. Uses Constraint if None.
Hook to add a pre create validation method.
This may be set to a function that expects one argument, the entity object. It will then be called before creating the object at the ICAT server. The function is expected to raise an exception (preferably ValueError) in case of validation errors.
Get the corresponding instance from an object.
Translate a list of objects into the list of corresponding instances.
Get information on an attribute.
Query the EntityInfo of the entity from the ICAT server and retrieve information on one of the attributes from it.
| Parameters: |
|
|---|---|
| Returns: | information on the attribute. |
| Raises ValueError: | |
if this is an abstract entity class or if no attribute by that name is found. |
|
Return the natural order of this class.
The order is a list of attributes suitable to be used in a ORDER BY clause in an ICAT search expression. The natural order is the one that is as close as possible to sorting the objects by the icat.entity.Entity.__sortkey__(). It is based on the Constraint of the class or the SortAttrs, if the latter are defined. In any case, one to many relationships and nullable many to one relationships are removed from the list.
Return a shallow copy of this entity object.
Create a new object that has all attributes set to a copy of the corresponding values of this object. The relations are copied by reference, i.e. the original and the copy refer to the same related object.
>>> inv = client.new("investigation", name="Investigation A")
>>> ds = client.new("dataset", investigation=inv, name="Dataset X")
>>> cds = ds.copy()
>>> cds.name
'Dataset X'
>>> cds.investigation.name
'Investigation A'
>>> cds.name = "Dataset Y"
>>> cds.investigation.name = "Investigation B"
>>> ds.name
'Dataset X'
>>> ds.investigation.name
'Investigation B'
Get the type of an attribute.
Query this object’s EntityInfo from the ICAT server and retrieve the type of one of the attributes from it. In the case of a relation attribute, this yields the BeanName of the related object.
| Parameters: | attr (str) – name of the attribute. |
|---|---|
| Returns: | name of the attribute type. |
| Return type: | str |
| Raises ValueError: | |
| if no attribute by that name is found. | |
Delete all relationships.
Delete all attributes having relationships to other objects from this object. Note that this is a local operation on the object in the client only. It does not affect the corresponding object at the ICAT server. This is useful if you only need to keep the object’s attributes but not the (possibly large) tree of related objects in local memory.
Return a unique kay.
The key is a string that is guaranteed to be unique for all entities in the ICAT. All attributes that form the uniqueness constraint must be set. A icat.client.Client.search() or icat.client.Client.get() with the appropriate INCLUDE statement may be required before calling this method. Note that this may be a problem with ICAT versions older then 4.3.0, because in these versions, the schema did allow constraint attributes and relations to be NULL in some cases. That means, it may happen that this method fails to create a unique key when connected to an old server.
If autoget is True the method will call icat.client.Client.get() with the appropriate arguments to fill the relations needed for the constraint. Note that this may discard information on other relations currently present in the entity object.
Deprecated since version 0.9: Using the autoget argument is obsolete. Call icat.client.Client.search() or icat.client.Client.get() with the appropriate INCLUDE statement instead.
if keyindex is not None, it is used as a cache of previously generated keys. It must be a dict that maps entity ids to the keys returned by previous calls of icat.entity.Entity.getUniqueKey() on other entity objects. The newly generated key will be added to this index.
| Parameters: |
|
|---|---|
| Returns: | a unique key. |
| Return type: | str |
| Raises DataConsistencyError: | |
if a relation required in a constraint is not set. |
|
Call icat.client.Client.create() to create the object in the ICAT.
Call icat.client.Client.update() to update the object in the ICAT.
Call icat.client.Client.get() to get the object from the ICAT.