One handler is created per model instead of per bound image spec.
This cuts down on the number of handlers created, and also offloads the
policing of the handlers in memory to the signal framework. Since they are no
longer being created per spec, the handlers can be weakly referenced.
Removed the save and clear_cache methods from ImageModel (along with helpers).
Now, whenever an ImageSpec is contributed to a model, handlers are created for
the post_save and post_delete signals. The post_save handler does the work of
running the ImageSpec processors and caching the resulting file, while the
post_delete handler does the work cleaning up the cached files.
The Format processor was really a special case and didn't do any
processing at all. Instead, ImageSpec just knew to look for it and
responded accordingly. Therefore, it's been replaced with a `format`
property on ImageSpec. This warranted a deeper look at how the format
and extension were being deduced (when not explicitly provided); the
results are documented in-code, though the goal was "no surprises."
You're no longer restricted to just one, special-case admin thumbnail. Make as
many as you want by adding AdminThumbnailView properties to your model and
including them in your admin class's `list_display` tuple. You can also provide
a custom template. Note that (because this change introduces templates to
imagekit), imagekit is now required in INSTALLED_APPS.
Ideally we could get this stuff out of the model, but we'll have to look into
whether that's possible without making things really complicated.
By creating the Descriptor using contribute_to_class (instead of in
ImageModelBase's __init__), we take the first step towards eliminating the need
to extend ImageModel at all.
Removed the cache_dir, cache_filename_fields and cache_filename_format
properties of IKOptions. While these were very powerful, I felt that it was
unnecessarily confusing to have two properties (cache_dir and
cache_filename_format) that determine the filename. The new cache_to property is
modeled after ImageField's upload_to and behaves almost identically (the only
exception being that a callable value receives different arguments). In
addition, I felt that the interpolation of model properties provided by
cache_filename_fields, though useful, would be better handled by a utility
function outside of this library.
This works kind of like Django's models' _default_manager. If your specs don't
specify an image_field, and your IKOptions don't specify a default_image_field,
the first ImageField your model defines will be used.
Tests were failing because they assumed that the file was deleted upon
teardown. This isn't the case after Django 1.3, where this no longer
happens. This fix removes any orphaned files (and directories) that were
created via the testing process.
* release/0.4.0:
Think it's time to bump to 0.4.0.
Adding Markus and Matt to AUTHORS.
Added ability to specify specs in IKOptions directly.
Improve fault tolerance of Accessor._delete()
fix issue #12
proper python comments in readme
Adding Josh to the contributors list.
Being a good PyPI citizen.
allowing any fields on the object to be specified for use in naming of generated images; default to allowing pk
Added the pk of the object into the dictionary of values passed to the string formatting for cache_filename.
Added the quality property in the readme's ImageSpec classes just to show it is possible to change it at will.
Fixes: CMYK files from Photoshop fails to load with exception -2