stalker.models.entity.SimpleEntity¶
-
class
stalker.models.entity.SimpleEntity(name=None, description=”, generic_text=”, type=None, created_by=None, updated_by=None, date_created=None, date_updated=None, thumbnail=None, html_style=”, html_class=”, **kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.BaseThe base class of all the others
The
SimpleEntityis the starting point of the Stalker Object Model, it starts by adding the basic information about an entity which arename,description, the audit information likecreated_by,updated_by,date_created,date_updatedand a couple of naming attributes likenice_nameand last but not least thetypeattribute which is very important for entities that needs a type.Note
For derived classes if the
SimpleEntity.typeneeded to be specifically specified, that is it can not be None or nothing else then aTypeinstance, set thestrictly_typedclass attribute to True:class NewClass(SimpleEntity): __strictly_typed__ = True
This will ensure that the derived class always have a proper
SimpleEntity.typeattribute and can not be initialized without one.Two SimpleEntities considered to be equal if they have the same
name, the other attributes doesn’t matter.New in version 0.2.0: Name attribute can be skipped. Starting from version 0.2.0 the
nameattribute can be skipped. For derived classes use the__auto_name__class attribute to control auto naming behaviour.Parameters: - name (string) –
A string value that holds the name of this entity. It should not contain any white space at the beginning and at the end of the string. Valid characters are [a-zA-Z0-9_/S].
Advanced:
For classes derived from the SimpleEntity, if an automatic name is desired, the “__auto_name__“ class attribute can be set to True. Then Stalker will automatically generate a uuid4 sequence for the name attribute.
- description (str) – A string attribute that holds the description of this entity object, it could be an empty string, and it could not again have white spaces at the beginning and at the end of the string, again any given objects will be converted to strings
- generic_text (str) – A string attribute that holds any text based information that should be affiliated with this entity, it could be an empty string, and it could not again have white spaces at the beginning and at the end of the string, again any given objects will be converted to strings.
- created_by (
User) – TheUserwho has created this object - updated_by – The
Userwho has updated this object lastly. The created_by and updated_by attributes point the same object if this object is just created. - date_created (
datetime.datetime) – The date that this object is created. - date_updated (
datetime.datetime) – The date that this object is updated lastly. For newly created entities this is equal to date_created and the date_updated cannot point a date which is before date_created. - type (
Type) – The type of the current SimpleEntity. Used across several places in Stalker. Can be None. The default value is None.
-
__init__(name=None, description=”, generic_text=”, type=None, created_by=None, updated_by=None, date_created=None, date_updated=None, thumbnail=None, html_style=”, html_class=”, **kwargs)¶
Methods
__init__([name, description, generic_text, …])Attributes
created_byThe Userwho has created this object.created_by_idThe id of the Userwho has created this entity.date_createdA datetime.datetimeinstance showing the creation date and time of this object.date_updatedA datetime.datetimeinstance showing the update date and time of this object.descriptionDescription of this object. entity_groupsentity_typegeneric_dataThis attribute can hold any kind of data which exists in SOM. generic_textThis attribute can hold any text. html_classhtml_styleidmetadatanameName of this object nice_nameNice name of this object. plural_class_namethe plural name of this class querythumbnailthumbnail_idtjp_idreturns TaskJuggler compatible id to_tjprenders a TaskJuggler compliant string used for TaskJuggler typeThe type of the object. type_idThe id of the Typeof this entity.updated_byThe Userwho has updated this object.updated_by_idThe id of the Userwho has updated this entity.-
type_id¶ The id of the
Typeof this entity. Mainly used by SQLAlchemy to create a Many-to-One relates between SimpleEntities and Types.
-
generic_data¶ This attribute can hold any kind of data which exists in SOM.
-
name¶ Name of this object
-
description¶ Description of this object.
-
date_created¶ A
datetime.datetimeinstance showing the creation date and time of this object.
-
date_updated¶ A
datetime.datetimeinstance showing the update date and time of this object.
-
type¶ The type of the object.
It is a
Typeinstance with a properType.target_entity_type.
-
generic_text¶ This attribute can hold any text.
-
nice_name¶ Nice name of this object.
It has the same value with the name (contextually) but with a different format like, all the white spaces replaced by underscores (“_”), all the CamelCase form will be expanded by underscore (_) characters and it is always lower case.
-
tjp_id¶ returns TaskJuggler compatible id
-
to_tjp¶ renders a TaskJuggler compliant string used for TaskJuggler integration. Needs to be overridden in inherited classes.
-
plural_class_name¶ the plural name of this class
- name (string) –