diff --git a/MANIFEST.in b/MANIFEST.in index 27e27bd..0adbc50 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,5 @@ include AUTHORS include LICENSE +include README.rst +recursive-include docs * +recursive-include imagekit/templates * diff --git a/README.rst b/README.rst index c423623..b52319c 100644 --- a/README.rst +++ b/README.rst @@ -7,7 +7,7 @@ Installation ------------ 1. ``pip install django-imagekit`` - (or clone the source and put the imagekit module on your path) + (or clone the source and put the imagekit module on your path) 2. Add ``'imagekit'`` to your ``INSTALLED_APPS`` list in your project's settings.py @@ -85,7 +85,7 @@ Admin ImageKit also contains a class named ``imagekit.admin.AdminThumbnail`` for displaying specs (or even regular ImageFields) in the -`Django admin change list`__. AdminThumbnail is used as a property on +`Django admin change list`_. AdminThumbnail is used as a property on Django admin classes:: from django.contrib import admin @@ -103,6 +103,4 @@ Django admin classes:: AdminThumbnail can even use a custom template. For more information, see ``imagekit.admin.AdminThumbnail``. - -__ https://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-change-list -__ https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display +.. _`Django admin change list`: https://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-change-list diff --git a/docs/conf.py b/docs/conf.py index a751d2c..4005268 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'2011, Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett & # built documents. # # The short X.Y version. -version = '1.0alpha' +version = '1.0.1' # The full version, including alpha/beta/rc tags. -release = '1.0alpha' +release = '1.0.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/imagekit/__init__.py b/imagekit/__init__.py index c12553b..93b5287 100644 --- a/imagekit/__init__.py +++ b/imagekit/__init__.py @@ -1,5 +1,4 @@ __title__ = 'django-imagekit' __author__ = 'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett, Matthew Tretter, Eric Eldredge' -__version__ = (1, 0, 0, 'final', 0) -__build__ = 0x001000 +__version__ = (1, 0, 1, 'final', 0) __license__ = 'BSD' diff --git a/imagekit/models.py b/imagekit/models.py index 815a972..435d58b 100755 --- a/imagekit/models.py +++ b/imagekit/models.py @@ -95,10 +95,15 @@ class ImageSpec(_ImageSpecMixin): dispatch_uid='%s.delete' % uid) +def get_registered_extensions(): + Image.preinit() + return Image.EXTENSION + + def _get_suggested_extension(name, format): if format: # Try to look up an extension by the format. - extensions = [k for k, v in Image.EXTENSION.iteritems() \ + extensions = [k for k, v in get_registered_extensions().iteritems() \ if v == format.upper()] else: extensions = [] @@ -124,7 +129,7 @@ class _ImageSpecFileMixin(object): # The extension is explicit, so assume they want the matching format. extension = os.path.splitext(filename)[1].lower() # Try to guess the format from the extension. - format = Image.EXTENSION.get(extension) + format = get_registered_extensions().get(extension) format = format or img.format or original_format or 'JPEG' if format != 'JPEG': @@ -237,22 +242,26 @@ class ImageSpecFile(_ImageSpecFileMixin, ImageFieldFile): control this by providing a `cache_to` method to the ImageSpec. """ - filename = self.source_file.name - if filename: - cache_to = self.field.cache_to or self._default_cache_to + name = getattr(self, '_name', None) + if not name: + filename = self.source_file.name + new_filename = None + if filename: + cache_to = self.field.cache_to or self._default_cache_to - if not cache_to: - raise Exception('No cache_to or default_cache_to value specified') - if callable(cache_to): - new_filename = force_unicode(datetime.datetime.now().strftime( \ - smart_str(cache_to(self.instance, self.source_file.name, - self.attname, self._suggested_extension)))) - else: - dir_name = os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(cache_to)))) - filename = os.path.normpath(os.path.basename(filename)) - new_filename = os.path.join(dir_name, filename) + if not cache_to: + raise Exception('No cache_to or default_cache_to value specified') + if callable(cache_to): + new_filename = force_unicode(datetime.datetime.now().strftime( \ + smart_str(cache_to(self.instance, self.source_file.name, + self.attname, self._suggested_extension)))) + else: + dir_name = os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(cache_to)))) + filename = os.path.normpath(os.path.basename(filename)) + new_filename = os.path.join(dir_name, filename) - return new_filename + self._name = new_filename + return self._name @name.setter def name(self, value): diff --git a/setup.py b/setup.py index 579d7ee..46aef9a 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,8 @@ setup( license='BSD', url='http://github.com/jdriscoll/django-imagekit/', packages=find_packages(), + zip_safe=False, + include_package_data=True, classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Web Environment',