stalker.models.structure.Structure

Inheritance diagram of stalker.models.structure.Structure
class stalker.models.structure.Structure(templates=None, custom_template=None, **kwargs)[source]

Bases: stalker.models.entity.Entity

Defines folder structures for Projects.

Structures are generally owned by Project objects. Whenever a Project is physically created, project folders are created by looking at Structure.custom_template of the Structure, the Project object is generally given to the Structure. So it is possible to use a variable like “{{project}}” or derived variables like:

{% for seq in project.sequences %}
    {{do something here}}

Every line of this rendered template will represent a folder and Stalker will create these folders on the attached Repository.

Parameters:
  • templates (list of FilenameTemplates) – A list of FilenameTemplates which defines a specific template for the given FilenameTemplate.target_entity_types.
  • custom_template (str) –

    A string containing several lines of folder names. The folders are relative to the Project root. It can also contain a Jinja2 Template code. Which will be rendered to show the list of folders to be created with the project. The Jinja2 Template is going to have the {{project}} variable. The important point to be careful about is to list all the custom folders of the project in a new line in this string. For example a Structure for a Project can have the following Structure.custom_template:

    ASSETS
    {% for asset in project.assets %}
        {% set asset_root = ‘ASSETS/’ + asset.code %}
        {{asset_root}}
    
        {% for task in asset.tasks %}
            {% set task_root = asset_root + ‘/’ + task.code %}
            {{task_root}}
    
    SEQUENCES
    {% for seq in project.sequences %}}
        {% set seq_root = ‘SEQUENCES/’ + {{seq.code}} %}
        {{seq_root}}/Edit
        {{seq_root}}/Edit/Export
        {{seq_root}}/Storyboard
    
        {% for shot in seq.shots %}
            {% set shot_root = seq_root + ‘/SHOTS/’ + shot.code %}
            {{shot_root}}
    
            {% for task in shot.tasks %}
                {% set task_root = shot_root + ‘/’ + task.code %}
                {{task_root}}
    

    The above example has gone far beyond deep than it is needed, where it started to define paths for Assets. Even it is possible to create a Project structure like that, in general it is unnecessary. Because the above folders are going to be created but they are probably going to be empty for a while, because the Assets are not created yet (or in fact no Versions are created for the Tasks). Anyway, it is much suitable and desired to create this details by using FilenameTemplate objects. Which are specific to certain FilenameTemplate.target_entity_types. And by using the Structure.custom_template attribute, Stalker can not place any source or output file of a Version in the Repository where as it can by using FilenameTemplates.

    But for certain types of Tasks it is may be good to previously create the folder structure just because in certain environments (programs) it is not possible to run a Python code that will place the file in to the Repository like in Photoshop.

    The custom_template parameter can be None or an empty string if it is not needed.

A Structure can not be created without a type (__strictly_typed__ = True). By giving a type to the Structure, you can create one structure for Commercials and another project structure for Movies and another one for Print projects etc. and can reuse them with new Projects.

__init__(templates=None, custom_template=None, **kwargs)

Methods

__init__([templates, custom_template])

Attributes

created_by The User who has created this object.
created_by_id The id of the User who has created this entity.
custom_template
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_id
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.
notes All the Notess attached to this entity.
plural_class_name the plural name of this class
query
structure_id
tags A list of tags attached to this object.
templates
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

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.

generic_data

This attribute can hold any kind of data which exists in SOM.

generic_text

This attribute can hold any text.

name

Name of this object

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.

notes

All the Notess attached to this entity.

It is a list of Note instances or an empty list, setting it to None will raise a TypeError.

plural_class_name

the plural name of this class

tags

A list of tags attached to this object.

It is a list of Tag instances which shows the tags of this object

tjp_id

returns TaskJuggler compatible id

to_tjp

renders a TaskJuggler compliant string used for TaskJuggler integration. Needs to be overridden in inherited classes.

type

The type of the object.

It is a Type instance with a proper Type.target_entity_type.

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.

updated_by

The User who has updated this object.

updated_by_id

The id of the User who has updated this entity.