Skip to content

Commit

Permalink
0.2.17.5
Browse files Browse the repository at this point in the history
========

* **Fix:** Fixed the ``image_format`` attribute implementation in ``Shot`` class. Now it will not copy the value of ``Project.image_format`` directly on ``__init__`` but instead will only store the value if the ``image_format`` argument in ``__init__`` or ``Shot.image_format`` attribute is set to something.
  • Loading branch information
eoyilmaz committed Dec 18, 2016
1 parent 8bc5b79 commit befc566
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG
Expand Up @@ -2,6 +2,15 @@
Stalker Changes
===============

0.2.17.5
========

* **Fix:** Fixed the ``image_format`` attribute implementation in ``Shot``
class. Now it will not copy the value of ``Project.image_format`` directly on
``__init__`` but instead will only store the value if the ``image_format``
argument in ``__init__`` or ``Shot.image_format`` attribute is set to
something.

0.2.17.4
========

Expand Down
2 changes: 1 addition & 1 deletion stalker/__init__.py
Expand Up @@ -23,7 +23,7 @@

import sys

__version__ = '0.2.17.4'
__version__ = '0.2.17.5'


__string_types__ = []
Expand Down
48 changes: 33 additions & 15 deletions stalker/models/shot.py
Expand Up @@ -179,7 +179,7 @@ class Shot(Task, CodeMixin):
)

image_format_id = Column(Integer, ForeignKey("ImageFormats.id"))
image_format = relationship(
_image_format = relationship(
"ImageFormat",
primaryjoin="Shots.c.image_format_id==ImageFormats.c.id",
doc="""The :class:`.ImageFormat` of this shot.
Expand Down Expand Up @@ -584,23 +584,41 @@ def _validate_scenes(self, key, scene):
)
return scene

@validates('image_format')
def _validate_image_format(self, key, imf):
def _image_format_getter(self):
"""returns the image_format value from the Project or from the
_image_format attribute
"""
if self._image_format is None:
return self.project.image_format
else:
return self._image_format

def _image_format_setter(self, imf_in):
"""sets the image_format value
"""
self._image_format = self._validate_image_format(imf_in)

image_format = synonym(
'_image_format',
descriptor=property(_image_format_getter, _image_format_setter),
doc='The image_format of this shot. Set it to None to re-sync with '
'Project.image_format.'
)

def _validate_image_format(self, imf):
"""validates the given imf value
"""
if imf is None:
# use the projects image format
from stalker import db
with db.DBSession.no_autoflush:
imf = self.project.image_format

if imf is not None:
if not isinstance(imf, ImageFormat):
raise TypeError(
'%s.image_format should be an instance of '
'stalker.models.format.ImageFormat, not %s' %
(self.__class__.__name__, imf.__class__.__name__)
)
# do not set it to anything it will automatically use the proejct
# image format
return None

if not isinstance(imf, ImageFormat):
raise TypeError(
'%s.image_format should be an instance of '
'stalker.models.format.ImageFormat, not %s' %
(self.__class__.__name__, imf.__class__.__name__)
)

return imf

Expand Down

0 comments on commit befc566

Please sign in to comment.