django-imagekit/imagekit/models/fields/utils.py
Matthew Tretter fe803f8981 Beginning to move functionality into "sources"
Before this is applied, we're going to have to make it so that the
image cache strategies are passed the source file, not the other file.
2012-10-10 00:18:54 -04:00

19 lines
576 B
Python

from .files import ImageSpecFieldFile
class ImageSpecFileDescriptor(object):
def __init__(self, field, attname):
self.attname = attname
self.field = field
def __get__(self, instance, owner):
if instance is None:
return self.field
else:
img_spec_file = ImageSpecFieldFile(instance, self.field,
self.attname)
instance.__dict__[self.attname] = img_spec_file
return img_spec_file
def __set__(self, instance, value):
instance.__dict__[self.attname] = value