Previous topic

stalker.core.models.types.LinkType

Next topic

stalker.core.models.user

This Page

stalker.core.models.types.TypeTemplate

Inheritance diagram of stalker.core.models.types.TypeTemplate

class stalker.core.models.types.TypeTemplate(path_code='', file_code='', type=None, **kwargs)[source]

Bases: stalker.core.models.entity.Entity

The TypeTemplate model holds templates for Types.

TypeTemplate objects help to specify where to place a file related to TypeEntity objects and its derived classes.

The first very important usage of TypeTemplates is to place asset Version‘s to proper places inside a Project‘s Structure.

Parameters:
  • path_code – The Jinja2 template code which specifies the path of the given item. It is relative to the project root which is in general {{repository.path}}/{{project.code}}/
  • file_code – The Jinja2 template code which specifies the file name of the given item
  • type_ – A TypeEntity object or any other class which is derived from TypeEntity.

Examples:

A template for asset versions can have this parameters:

from stalker import db
from satlker.db import auth
from stalker.core.models import types, pipelineStep

# setup the default database
db.setup()

# store the query method for ease of use
session = db.session
query = db.session.query

# login to the system as admin
admin = auth.login("admin", "admin")

# create a couple of variables
path_code = "ASSETS/{{asset_type.name}}/{{pipeline_step.code}}"

file_code = "{{asset.name}}_{{take.name}}_{{asset_type.name}}_v{{version.version_number}}"

# create a pipeline step object
modelingStep = pipelineStep.PipelineStep(
    name="Modeling",
    code="MODEL",
    description="The modeling step of the asset",
    created_by=admin
)

# create a "Character" AssetType with only one step
typeObj = types.AssetType(
    name="Character",
    description="this is the character asset type",
    created_by=admin,
    steps=[modelingStep]
)

# now create our TypeTemplate
char_template = types.TypeTemplate(
    name="Character",
    description="this is the template which explains how to place Character assets",
    path_code=path_code,
    file_code=file_code,
    type=typeObj,
)

# assign this type template to the structure of the project with id=101
myProject = query(project.Project).filter_by(id=101).first()

# append the type template to the structures' asset templates
myProject.structure.asset_templates.append(char_template)

session.commit()

Now with the code above, whenever a new Version created for a Character asset, Stalker will automatically place the related file to a certain folder and with a certain file name defined by the template. For example the above template should render something like below for Windows:

|- M:\\PROJECTS  --> {{repository.path}}
 |- PRENSESIN_UYKUSU  --> {{project.code}}
  |- ASSETS  --> "ASSETS"
   |- Character  --> {{asset_type.name}}
    |- Olum  --> {{asset.name}}
     |- MODEL  --> {{pipeline_step.code}}
      |- Olum_MAIN_MODEL_v001.ma --> {{asset.name}}_{{take.name}}_{{asset_type.name}}_v{{version.version_number}}

And one of the good side is you can create a version from Linux, Windows or OSX all the paths will be correctly handled by Stalker.

__init__(path_code='', file_code='', type=None, **kwargs)[source]

Methods

__init__(**kwargs[, path_code, file_code, type])

Attributes

code The code name of this object.
created_by The User who has created
date_created A datetime.datetime instance showing the creation
date_updated A datetime.datetime instance showing the update
description Description of this object.
file_code this is the property that helps you assign values to
name name of this object
nice_name The nice name of this object.
notes all the notes about this entity, it should be a list of Notes
path_code this is the property that helps you assign values to
tags a list of Tag objects which shows the related tags to the
type the target type this template should work on, should be an
updated_by The User who has updated
path_code[source]

this is the property that helps you assign values to path_code attribute

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 to the uppercase form of the nice_name attribute. If the 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.

file_code[source]

this is the property that helps you assign values to file_code attribute

name

name of this object

nice_name

The 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 should be a list of Notes objects or an empty list, None is not accepted

tags

a list of Tag objects which shows the related tags to the entity

updated_by

The User who has updated this object.

type[source]

the target type this template should work on, should be an instance of TypeEntity