diff --git a/imagekit/admin.py b/imagekit/admin.py index 7a9e145..6b37a4c 100644 --- a/imagekit/admin.py +++ b/imagekit/admin.py @@ -30,7 +30,7 @@ class AdminThumbnail(object): raise Exception('The property %s is not defined on %s.' % (self.image_field, obj.__class__.__name__)) - original_image = getattr(thumbnail, 'source_file', None) or thumbnail + original_image = getattr(thumbnail, 'source', None) or thumbnail template = self.template or 'imagekit/admin/thumbnail.html' return render_to_string(template, { diff --git a/imagekit/management/commands/warmimagecache.py b/imagekit/management/commands/warmimagecache.py index 35695af..6c9822d 100644 --- a/imagekit/management/commands/warmimagecache.py +++ b/imagekit/management/commands/warmimagecache.py @@ -20,10 +20,10 @@ class Command(BaseCommand): for spec_id in specs: self.stdout.write('Validating spec: %s\n' % spec_id) for source_group in source_group_registry.get(spec_id): - for source_file in source_group.files(): - if source_file: - spec = generator_registry.get(spec_id, source_file=source_file) # TODO: HINTS! (Probably based on source, so this will need to be moved into loop below.) - self.stdout.write(' %s\n' % source_file) + for source in source_group.files(): + if source: + spec = generator_registry.get(spec_id, source=source) # TODO: HINTS! (Probably based on source, so this will need to be moved into loop below.) + self.stdout.write(' %s\n' % source) try: # TODO: Allow other validation actions through command option GeneratedImageCacheFile(spec).validate() diff --git a/imagekit/models/fields/utils.py b/imagekit/models/fields/utils.py index 07c6e9e..39dbc52 100644 --- a/imagekit/models/fields/utils.py +++ b/imagekit/models/fields/utils.py @@ -13,7 +13,7 @@ class ImageSpecFileDescriptor(object): else: field_name = getattr(self.field, 'source', None) if field_name: - source_file = getattr(instance, field_name) + source = getattr(instance, field_name) else: image_fields = [getattr(instance, f.attname) for f in instance.__class__._meta.fields if @@ -28,8 +28,8 @@ class ImageSpecFileDescriptor(object): ' ImageSpecField.' % (instance.__class__.__name__, self.attname)) else: - source_file = image_fields[0] - spec = self.field.get_spec(source_file=source_file) # TODO: What "hints" should we pass here? + source = image_fields[0] + spec = self.field.get_spec(source=source) # TODO: What "hints" should we pass here? file = GeneratedImageCacheFile(spec) instance.__dict__[self.attname] = file return file diff --git a/imagekit/registry.py b/imagekit/registry.py index bdf3fd6..6ff9210 100644 --- a/imagekit/registry.py +++ b/imagekit/registry.py @@ -93,7 +93,7 @@ class SourceGroupRegistry(object): def before_access_receiver(self, sender, generator, file, **kwargs): generator.image_cache_strategy.invoke_callback('before_access', file) - def source_group_receiver(self, sender, source_file, signal, info, **kwargs): + def source_group_receiver(self, sender, source, signal, info, **kwargs): """ Redirects signals dispatched on sources to the appropriate specs. @@ -102,14 +102,14 @@ class SourceGroupRegistry(object): if source_group not in self._source_groups: return - for spec in (generator_registry.get(id, source_file=source_file, **info) + for spec in (generator_registry.get(id, source=source, **info) for id in self._sources_groups[source_group]): event_name = { source_created: 'source_created', source_changed: 'source_changed', source_deleted: 'source_deleted', } - spec._handle_source_event(event_name, source_file) + spec._handle_source_event(event_name, source) class Register(object): diff --git a/imagekit/specs/__init__.py b/imagekit/specs/__init__.py index fdf2044..de1db8d 100644 --- a/imagekit/specs/__init__.py +++ b/imagekit/specs/__init__.py @@ -45,7 +45,7 @@ class BaseImageSpec(object): raise NotImplementedError # TODO: I don't like this interface. Is there a standard Python one? pubsub? - def _handle_source_event(self, event_name, source_file): + def _handle_source_event(self, event_name, source): file = GeneratedImageCacheFile(self) self.image_cache_strategy.invoke_callback('on_%s' % event_name, file) @@ -84,15 +84,15 @@ class ImageSpec(BaseImageSpec): """ - def __init__(self, source_file, **kwargs): - self.source_file = source_file + def __init__(self, source, **kwargs): + self.source = source self.processors = self.processors or [] self.kwargs = kwargs super(ImageSpec, self).__init__() @property def cache_file_name(self): - source_filename = self.source_file.name + source_filename = self.source.name ext = suggest_extension(source_filename, self.format) return os.path.normpath(os.path.join( settings.IMAGEKIT_CACHE_DIR, @@ -104,7 +104,7 @@ class ImageSpec(BaseImageSpec): def get_hash(self): return md5(pickle.dumps([ - self.source_file, + self.source, self.kwargs, self.processors, self.format, @@ -115,9 +115,9 @@ class ImageSpec(BaseImageSpec): def generate(self): # TODO: Move into a generator base class # TODO: Factor out a generate_image function so you can create a generator and only override the PIL.Image creating part. (The tricky part is how to deal with original_format since generator base class won't have one.) - source_file = self.source_file + source = self.source filename = self.kwargs.get('filename') - img = open_image(source_file) + img = open_image(source) original_format = img.format # Run the processors diff --git a/imagekit/specs/sourcegroups.py b/imagekit/specs/sourcegroups.py index fe0b366..b36b211 100644 --- a/imagekit/specs/sourcegroups.py +++ b/imagekit/specs/sourcegroups.py @@ -94,7 +94,7 @@ class ModelSignalRouter(object): instance=instance, field_name=attname, ) - signal.send(sender=source_group, source_file=file, info=info) + signal.send(sender=source_group, source=file, info=info) class ImageFieldSourceGroup(object): diff --git a/imagekit/templatetags/imagekit.py b/imagekit/templatetags/imagekit.py index c917011..d5aa9c6 100644 --- a/imagekit/templatetags/imagekit.py +++ b/imagekit/templatetags/imagekit.py @@ -14,7 +14,7 @@ HTML_ATTRS_DELIMITER = 'with' _kwarg_map = { - 'from': 'source_file', + 'from': 'source', }