Storage can be specified on a per-spec basis.

If not defined on the spec, IKOptions.default_storage will be used. If that's
not defined, it will fall back to the image field's storage.
This commit is contained in:
Matthew Tretter 2011-09-09 23:23:27 -04:00
parent 57a28091c5
commit 8cfe485a5a
2 changed files with 10 additions and 2 deletions

View file

@ -20,6 +20,12 @@ class Options(object):
"""
default_storage = None
"""Storage used for specs that don't define their own storage explicitly.
If neither is specified, the image field's storage will be used.
"""
crop_horz_field = 'crop_horz'
crop_vert_field = 'crop_vert'
preprocessor_spec = None
@ -28,7 +34,6 @@ class Options(object):
cache_filename_fields = ['pk', ]
cache_filename_format = "%(filename)s_%(specname)s.%(extension)s"
specs = None
#storage = defaults to image_field.storage
def __init__(self, opts):
for key, value in opts.__dict__.iteritems():

View file

@ -20,6 +20,7 @@ class ImageSpec(object):
pre_cache = False
quality = 70
increment_count = False
storage = None
def __init__(self, processors=None, **kwargs):
if processors:
@ -116,7 +117,9 @@ class Accessor(object):
@property
def _storage(self):
return getattr(self._obj._ik, 'storage', self._imgfield.storage)
return getattr(self.spec, 'storage', None) or \
getattr(self._obj._ik, 'default_storage', None) or \
self._imgfield.storage
@property
def url(self):