stalker.core.models.Structure — Stalker v0.1.1.a9 documentation

### Navigation

- index
- next |
- previous |
- Stalker v0.1.1.a9 documentation »

# stalker.core.models.Structure

class `stalker.core.models.` `Structure`(templates=None, custom_template=None, **kwargs)

  Bases: `stalker.core.models.Entity`

  A structure object is the place to hold data about how the physical files are arranged in the `Repository`.

  Structures are generally owned by `Project` objects. Whenever a `Project` is physicaly created, project folders are created by looking at `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}}

  - Parameters: | templates (list of `FilenameTemplate`s) – A list of `FilenameTemplate`s which defines a specific template for the given `target_entity_type`s. 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 `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/AnimaticStoryboard
            {{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 `Asset`s. 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 `Asset`s are not created yet (or in fact no `Version`s are created for the `Task`s). Anyway, it is much suitable and desired to create this details by using `FilenameTemplate` objects. Which are spesific to certain `target_entity_type`s. And by using the `custom_template` attribute, Stalker can not place any source or output file of a `Version` in the `Repository` where as it can by using `FilenameTemplate`s. But for certain types of `Task`s 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. Be carefull not to pass a variable other than a string or unicode because it will use the string representation of the given variable.

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

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

  Methods

  `__init__`(**kwargs[, templates, custom_template]) |

  Attributes

  `code` | The code name of this object.
  `created_by` | The `User` who has created this object.
  `custom_template` | A string value, which is a list of folder names.
  `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.
  `notes` | All the notes about this entity.
  `tags` | A list of tags attached to this object.
  `templates` | A list of `FilenameTemplate` instances.
  `type` | The type of the object.
  `updated_by` | The `User` who has updated this object.

  `custom_template`

    A string value, which is a list of folder names.

    It can also contain Jinja2 direction. See the `Structure` documentaion for more details.

  `templates`

    A list of `FilenameTemplate` instances.

    This list shows possible filenaming conventions created along with this `Structure` instance. It should be a list of `FilenameTemplate` instances.

  `code`

    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`

    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.

    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).

  `notes`

    All the notes about this entity.

    It is a list of `Note` objects or an empty list, None will be converted to an empty list.

  `tags`

    A list of tags attached to this object.

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

  `type`

    The type of the object.

    It is an instance of `Type` with a proper `target_entity_type`.

  `updated_by`

    The `User` who has updated this object.

### Navigation

- index
- next |
- previous |
- Stalker v0.1.1.a9 documentation »