django-imagekit/imagekit/models/fields/utils.py

20 lines
576 B
Python
Raw Normal View History

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)
2012-02-18 01:07:50 +00:00
instance.__dict__[self.attname] = img_spec_file
return img_spec_file
2012-02-18 01:07:50 +00:00
def __set__(self, instance, value):
instance.__dict__[self.attname] = value