Previous topic

stalker.core.models.Shot

Next topic

stalker.core.models.Status

This Page

stalker.core.models.SimpleEntity

Inheritance diagram of stalker.core.models.SimpleEntity

class stalker.core.models.SimpleEntity(name=None, description='', type=None, created_by=None, updated_by=None, date_created=datetime.datetime(2011, 6, 30, 23, 5, 54, 355639), date_updated=datetime.datetime(2011, 6, 30, 23, 5, 54, 355655), code=None, **kwargs)[source]

Bases: object

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 informations like created_by, updated_by, date_created, date_updated and a couple of naming attributes like code and nice_name and last but not least the type attribute which is very important for entities that needs a type.

For derived classes if the 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 type attribute and can not initialize without one.

Two SimpleEntities considered to be equal if they have the same name, the other attributes doesn’t matter.

The formatting rules for the code attribute is as follows:

  • only alphanumerics and underscore is allowed [a-zA-Z0-9_]
  • no number is allowed at the beggining
  • no white spaces are allowed
  • all the white spaces will be converted to underscore characters
  • all the underscores are converted to only one underscore character if more than one follows each other

Examples:

Input Value Formatted Output
testCode testCode
1testCode testCode
_testCode testCode
2423$+^^+^’%+%%&_testCode testCode
2423$+^^+^’%+%%&_testCode_35 testCode_35
2423$ +^^+^ ‘%+%%&_ testCode_ 35 testCode_35
SH001 SH001
My CODE is Ozgur My_CODE_is_Ozgur
this is another code for an asset this_is_another_code_for_an_asset
Parameters:
  • name (string) – A string or unicode value that holds the name of this entity. It can not be empty, the first letter should be an alphabetic ([a-zA-z]) (not alphanumeric [a-zA-Z0-9]) letter and it should not contain any white space at the beggining and at the end of the string, giving an object the object will be converted to string and then the resulting string will be conditioned.
  • description (str) – A string or unicode 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 beggining 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 thedate_updated cannot point a date which is before date_created.
  • code (str) – The code name of this object. It accepts string or unicode values and any other kind of objects will be converted to string. Can be omitted and it will be set to the same value of the nice_name attribute. If both the name and code arguments are given the code attribute will be set to the given code argument value, but in any update to name attribute the code also will be updated to the nice_name attribute. When the code is directly edited the code will not be formated other than removing any illegal characters. The default value is the same value of the nice_name.
  • 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='', type=None, created_by=None, updated_by=None, date_created=datetime.datetime(2011, 6, 30, 23, 5, 54, 355639), date_updated=datetime.datetime(2011, 6, 30, 23, 5, 54, 355655), code=None, **kwargs)[source]

Methods

__init__(6, 30, 23, 5, 54, 6, 30, 23, 5, 54, ...)

Attributes

code The code name of this object.
created_by The User who has created 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.
description Description of this object.
name Name of this object
nice_name Nice name of this object.
type The type of the object.
updated_by The User who has updated this object.
description[source]

Description of this object.

name[source]

Name of this object

nice_name[source]

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.

There is also the code attribute which is simply the upper case form of nice_name if it is not defined differently (i.e set to another value).

type[source]

The type of the object.

It is an instance of Type with a proper target_entity_type.

code[source]

The code name of this object.

It accepts string or unicode values and any other kind of objects will be converted to string. In any update to the name attribute the code also will be updated. If the code is not initialized or given as None, it will be set to the uppercase version of the nice_name attribute. Setting the code attribute to None will reset it to the default value. The default value is the upper case form of the nice_name.

created_by[source]

The User who has created this object.

updated_by[source]

The User who has updated this object.

date_created[source]

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

date_updated[source]

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