sol.models -- SQLAlchemy modelization

The application's model objects

class sol.models.Base(**kwargs: Any)

Abstract base entity class.

caption(html=None, localized=True)

Return a possibly HTML-decorated caption of the entity.

Parameters:
  • html -- either None (the default) or a boolean value

  • localized -- a boolean value, True by default

Return type:

str

If html is None or True then the result may be an HTML representation of the entity, otherwise it is plain text.

If localized is False then the localization is turned off.

classmethod check_insert(session: Session, fields: dict[str, Any], user_id: str | int) None

Perform any check before an new instance is inserted.

Parameters:
  • session -- the SA session

  • fields -- a dictionary with the fields values

  • user_id -- either the string "admin" or the ID of the user performing the operation

check_update(fields: dict[str, Any], user_id: str | int) None

Perform any check before updating the instance.

Parameters:
  • fields -- a mapping containing fieldname -> value associations

  • user_id -- either the string "admin" or the ID of the user performing the operation

This implementation does nothing, but subclasses can override it at will, either to adapt incoming values or to check their validity, raising an exception if something is wrong.

delete() None

Delete this instance from the database.

update(data: dict[str, Any], user_id: str | int, *, missing_only=False) dict[str, tuple[Any, Any]]

Update entity with given data.

Parameters:
  • data -- a mapping kind of container

  • missing_only -- a boolean flag, False by default

  • user_id -- either the string "admin" or the ID of the user performing the operation

Return type:

dict

Returns:

a mapping between field name and a tuple (oldvalue, newvalue), for each modified field

First call check_update() to assert the validity of incoming data, then update the instance fields.

If missing_only is True then only the fields that are currently empty (that is, their value is either None or an empty string) are updated. Note that in this case an exception is made for bool fields: since in SoL they always have a value (i.e. they are never missing), they are always updated.

property description

Simple text description of the entity, basically an alias to caption().

class sol.models.GloballyUnique

Mixin class for globally unique identified entities.

guid

A global unique identifier for this entity.

modified: Mapped[datetime] = <sqlalchemy.orm.properties.MappedColumn object>

Last update timestamp.