stalker.models.entity.SimpleEntity

Inheritance diagram of 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.Base

The base class of all the others

The SimpleEntity is the starting point of the Stalker Object Model, it starts by adding the basic information about an entity which are name, description, the audit information like created_by, updated_by, date_created, date_updated and a couple of naming attributes like nice_name and last but not least the type attribute which is very important for entities that needs a type.

Note

For derived classes if the SimpleEntity.type needed to be specifically specified, that is it can not be None or nothing else then a Type instance, set the strictly_typed class attribute to True:

class NewClass(SimpleEntity):
    __strictly_typed__ = True

This will ensure that the derived class always have a proper SimpleEntity.type attribute 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 name attribute 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) – The User who has created this object
  • updated_by – The User who 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_by The User who has created this object.
created_by_id The id of the User who has created this entity.
date_created A datetime.datetime instance showing the creation date and time of this object.
date_updated A datetime.datetime instance showing the update date and time of this object.
description Description of this object.
entity_groups
entity_type
generic_data This attribute can hold any kind of data which exists in SOM.
generic_text This attribute can hold any text.
html_class
html_style
id
metadata
name Name of this object
nice_name Nice name of this object.
plural_class_name the plural name of this class
query
thumbnail
thumbnail_id
tjp_id returns TaskJuggler compatible id
to_tjp renders a TaskJuggler compliant string used for TaskJuggler
type The type of the object.
type_id The id of the Type of this entity.
updated_by The User who has updated this object.
updated_by_id The id of the User who has updated this entity.
created_by_id

The id of the User who has created this entity.

updated_by_id

The id of the User who has updated this entity.

type_id

The id of the Type of 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.

created_by

The User who has created this object.

updated_by

The User who has updated this object.

date_created

A datetime.datetime instance showing the creation date and time of this object.

date_updated

A datetime.datetime instance showing the update date and time of this object.

type

The type of the object.

It is a Type instance with a proper Type.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