Validate the image any time the file is required

This means that accessing `path` or `size` will also validate,
closing #109
This commit is contained in:
Matthew Tretter 2012-02-23 17:46:57 -05:00
parent 24a2d772a6
commit 3a5d7da0d8

View file

@ -36,12 +36,8 @@ class ImageSpecFieldFile(ImageFieldFile):
def _require_file(self):
if not self.source_file:
raise ValueError("The '%s' attribute's image_field has no file associated with it." % self.attname)
def _get_file(self):
self.validate()
return super(ImageFieldFile, self).file
file = property(_get_file, ImageFieldFile._set_file, ImageFieldFile._del_file)
else:
self.validate()
def clear(self):
return self.field.image_cache_backend.clear(self)
@ -61,11 +57,6 @@ class ImageSpecFieldFile(ImageFieldFile):
return self.field.generator.generate_file(self.name, self.source_file,
save)
@property
def url(self):
self.validate()
return super(ImageFieldFile, self).url
def delete(self, save=False):
"""
Pulled almost verbatim from ``ImageFieldFile.delete()`` and