Merge branch 'release/1.0.1'

* release/1.0.1:
  Bumping docs to 1.0.1.
  Bumping version to 1.0.1.
  Making sure the templates make it via pip. Fixes #39.
  Generated filename is cached
  Fixes extension guessing based on image format
  No longer an alpha.
  Including README.rst and the docs in MANIFEST.in. Fixes #40.
  Develop is now v1.1.0.dev.
  Slightly updated README to correctly render as reStructuredText.
This commit is contained in:
Bryan Veloso 2011-11-02 13:47:32 +09:00
commit d9a7640d56
6 changed files with 36 additions and 25 deletions

View file

@ -1,2 +1,5 @@
include AUTHORS
include LICENSE
include README.rst
recursive-include docs *
recursive-include imagekit/templates *

View file

@ -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

View file

@ -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.

View file

@ -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'

View file

@ -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):

View file

@ -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',