Previous topic

oyProjectManager.core.models.User

Next topic

oyProjectManager.core.models.VersionableBase

This Page

oyProjectManager.core.models.Version

Inheritance diagram of oyProjectManager.core.models.Version

class oyProjectManager.core.models.Version(version_of, base_name, type, created_by, take_name='MAIN', version_number=1, note='', extension='', is_published=False, status=None)[source]

Bases: sqlalchemy.ext.declarative.Base

Holds versions of assets or shots.

In oyProjectManager a Version is the file created for an Asset or Shot. The placement of this file is automatically handled by the connected VersionType instance.

The values given for base_name and take_name are conditioned as follows:

  • Each word in the string should start with an upper-case letter (title)
  • It can have all upper-case letters
  • CamelCase is allowed
  • Valid characters are ([A-Z])([a-zA-Z0-9_])
  • No white space characters are allowed, if a string is given with white spaces, it will be replaced with underscore (“_”) characters.
  • No numbers are allowed at the beginning of the string
  • No leading or trailing underscore character is allowed

So, with these rules are given, the examples for input and conditioned strings are as follows:

  • “BaseName” -> “BaseName”
  • “baseName” -> “BaseName”
  • ” baseName” -> “BaseName”
  • ” base name” -> “Base_Name”
  • ” 12base name” -> “Base_Name”
  • ” 12 base name” -> “Base_Name”
  • ” 12 base name 13” -> “Base_Name_13”
  • “>£#>$#£½$ 12 base £#$£#$£½¾{½{ name 13” -> “Base_Name_13”
  • “_base_name_” -> “Base_Name”

For a newly created Version the filename and the path attributes are rendered from the associated VersionType instance. The resultant filename and path values are stored and retrieved back from the Version instance itself, no re-rendering happens. It means, the Version class depends the VersionType class only at the initialization, any change made to the VersionType instance (like changing the name or code of the VersionType) will not effect the Version instances created before this change. This is done in that way to be able to freely change the VersionType attributes and prevent loosing the connection between a Version and a file on the repository for previously created Versions.

New in version 0.2.2: Published Versions:

After v0.2.2 Versions can be set published. It is a bool attribute holding information about if this Version is published or not.

Parameters:
  • version_of – A VersionableBase instance (Asset or Shot) which is the owner of this version. Can not be skipped or set to None.
  • type (VersionType) – A VersionType instance which is showing the type of the current version. The type is also responsible of the placement of this Version in the repository. So the filename and the path is defined by the related VersionType and the Project settings. Can not be skipped or can not be set to None.
  • base_name (str) – A string showing the base name of this Version instance. Generally used to create an appropriate filename and a path value. Can not be skipped, can not be None or empty string.
  • take_name (str) – A string showing the take name. The default value is “MAIN” and it will be used in case it is skipped or it is set to None or an empty string. Generally used to create an appropriate filename and a path value.
  • revision_number (int) – It is an integer number showing the client revision number. The default value is 0 and it is used when the argument is skipped or set to None. It should be an increasing number with the newly created versions.
  • version_number (int) – An integer number showing the current version number. It should be an increasing number among the Versions with the same base_name and take_name values. If skipped a proper value will be used by looking at the previous versions created with the same base_name and take_name values from the database. If the given value already exists then it will be replaced with the next available version number from the database.
  • note (str) – A string holding the related note for this version. Can be used for anything the user desires.
  • created_by (User) – A User instance showing who created this version. It can not be skipped or set to None or anything other than a User instance.
  • extension (str) – A string holding the file extension of this version. It may or may not include a dot (”.”) sign as the first character.
  • is_published (bool) – A bool value defining this Version as a published one.
__init__(version_of, base_name, type, created_by, take_name='MAIN', version_number=1, note='', extension='', is_published=False, status=None)[source]

Methods

__init__(version_of, base_name, type, created_by)
is_latest_published_version() returns True if this is the latest published Version False otherwise
is_latest_version() returns True if this is the latest Version False otherwise
latest_published_version() Returns the last published version.
latest_version() returns the Version instance with the highest version number in this
query()
save() commits the changes to the database
update_paths() updates the path variables

Attributes

base_name
created_by
created_by_id
dependency_update_list Calculates a list of Version
extension The extension of this version file, updating the extension will
filename The filename of this version.
full_path The full_path of this version.
id
is_published
max_version returns the maximum version number for this Version from the
metadata A collection of Table objects and their associated schema constructs.
note
output_path The output_path of this version.
path The path of this version.
project The Project instance that
references
revision_number
status The comparator class for Version.status
take_name
type The type of this Version instance.
type_id
version_number returns the version_number of this Version instance
version_of The instance that this version belongs to.
version_of_id
update_paths()[source]

updates the path variables

version_of[source]

The instance that this version belongs to.

Generally it is a Shot or an Asset instance or anything which derives from VersionableBase class

extension

The extension of this version file, updating the extension will also update the filename

type[source]

The type of this Version instance.

It is a VersionType object.

filename[source]

The filename of this version.

It is automatically created by rendering the VersionType.filename template with the information supplied with this Version instance.

path[source]

The path of this version.

It is automatically created by rendering the template in :class`~oyProjectManager.core.models.Version`. path of the with the information supplied by this Version instance.

The resultant path is an absolute one. But the stored path in the database is just the relative portion to the Repository. server_path

full_path[source]

The full_path of this version.

It is the join of Repository. server_path and Version. path and Version. filename attributes.

So, it is an absolute path. The value of the full_path is not stored in the database.

output_path[source]

The output_path of this version.

It is automatically created by rendering the VersionType. output_path template with the information supplied with this Version instance.

The resultant path is an absolute one. But the stored path in the database is just the relative portion to the Repository. server_path.

latest_version()[source]

returns the Version instance with the highest version number in this series

Returns:Version instance
max_version[source]

returns the maximum version number for this Version from the database.

Returns:int
version_number

returns the version_number of this Version instance

save()[source]

commits the changes to the database

project[source]

The Project instance that this Version belongs to

is_latest_version()[source]

returns True if this is the latest Version False otherwise

is_latest_published_version()[source]

returns True if this is the latest published Version False otherwise

latest_published_version()[source]

Returns the last published version.

Returns:Version
dependency_update_list[source]

Calculates a list of Version instances, which are referenced by this Version and has a newer version.

Also checks the references in the referenced Version and appends the resultant list to the current dependency_update_list. Resulting a much deeper update info.

Returns:list of Version instances.