From af73a939536413b8d9caebcff0c8f94c11867663 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Mon, 3 Jun 2013 10:31:57 -0300 Subject: [PATCH 1/9] Add import to example Closes #224 --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index c2b60a7..ae65e8a 100644 --- a/README.rst +++ b/README.rst @@ -177,7 +177,7 @@ to register it. .. code-block:: python - from imagekit import ImageSpec + from imagekit import ImageSpec, register from imagekit.processors import ResizeToFill class Thumbnail(ImageSpec): From 02cd1bf7ffd3066261cd969ecfcf339beb623629 Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Mon, 3 Jun 2013 12:50:20 -0700 Subject: [PATCH 2/9] I, for one, welcome our new @matthewwithanm overlords. --- AUTHORS | 2 +- CONTRIBUTING.rst | 2 +- README.rst | 12 ++++++------ imagekit/models/fields/__init__.py | 2 +- imagekit/specs/sourcegroups.py | 2 +- setup.py | 6 +++--- tests/test_sourcegroups.py | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/AUTHORS b/AUTHORS index 34c4c8d..255827b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,8 +6,8 @@ HZDG_. Maintainers ----------- -* `Bryan Veloso`_ * `Matthew Tretter`_ +* `Bryan Veloso`_ * `Chris Drackett`_ * `Greg Newman`_ diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index e36fd1c..b9f2de2 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -21,4 +21,4 @@ __ http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html __ https://groups.google.com/forum/#!forum/django-imagekit __ irc://irc.freenode.net/imagekit .. _nose: https://nose.readthedocs.org/en/latest/ -__ https://github.com/jdriscoll/django-imagekit/tree/develop/tests +__ https://github.com/matthewwithanm/django-imagekit/tree/develop/tests diff --git a/README.rst b/README.rst index ae65e8a..53e8781 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ |Build Status|_ -.. |Build Status| image:: https://travis-ci.org/jdriscoll/django-imagekit.png?branch=develop -.. _Build Status: https://travis-ci.org/jdriscoll/django-imagekit +.. |Build Status| image:: https://travis-ci.org/matthewwithanm/django-imagekit.png?branch=develop +.. _Build Status: https://travis-ci.org/matthewwithanm/django-imagekit ImageKit is a Django app for processing images. Need a thumbnail? A black-and-white version of a user-uploaded image? ImageKit will make them for @@ -371,7 +371,7 @@ it in your spec's ``processors`` list: options = {'quality': 60} Note that when you import a processor from ``imagekit.processors``, imagekit -in turn imports the processor from `PILKit`_. So if you are looking for +in turn imports the processor from `PILKit`_. So if you are looking for available processors, look at PILKit. .. _`PILKit`: https://github.com/matthewwithanm/pilkit @@ -414,7 +414,7 @@ of generator ids in order to generate images selectively. Community ========= -Please use `the GitHub issue tracker `_ +Please use `the GitHub issue tracker `_ to report bugs with django-imagekit. `A mailing list `_ also exists to discuss the project and ask questions, as well as the official `#imagekit `_ channel on Freenode. @@ -436,5 +436,5 @@ Check out our `contributing guidelines`__ for more information about pitching in with ImageKit. -__ https://github.com/jdriscoll/django-imagekit/issues?labels=contributor-friendly&state=open -__ https://github.com/jdriscoll/django-imagekit/blob/develop/CONTRIBUTING.rst +__ https://github.com/matthewwithanm/django-imagekit/issues?labels=contributor-friendly&state=open +__ https://github.com/matthewwithanm/django-imagekit/blob/develop/CONTRIBUTING.rst diff --git a/imagekit/models/fields/__init__.py b/imagekit/models/fields/__init__.py index 3f1a2f6..91c6252 100644 --- a/imagekit/models/fields/__init__.py +++ b/imagekit/models/fields/__init__.py @@ -39,7 +39,7 @@ class ImageSpecField(SpecHostField): cachefile_strategy=cachefile_strategy, spec=spec, spec_id=id) - # TODO: Allow callable for source. See https://github.com/jdriscoll/django-imagekit/issues/158#issuecomment-10921664 + # TODO: Allow callable for source. See https://github.com/matthewwithanm/django-imagekit/issues/158#issuecomment-10921664 self.source = source def contribute_to_class(self, cls, name): diff --git a/imagekit/specs/sourcegroups.py b/imagekit/specs/sourcegroups.py index dd804dc..2008f59 100644 --- a/imagekit/specs/sourcegroups.py +++ b/imagekit/specs/sourcegroups.py @@ -47,7 +47,7 @@ class ModelSignalRouter(object): ``ImageFieldSourceGroup``s. This class encapsulates that functionality. Related: - https://github.com/jdriscoll/django-imagekit/issues/126 + https://github.com/matthewwithanm/django-imagekit/issues/126 https://code.djangoproject.com/ticket/9318 """ diff --git a/setup.py b/setup.py index 393c019..da959a0 100644 --- a/setup.py +++ b/setup.py @@ -31,12 +31,12 @@ setup( version=pkgmeta['__version__'], description='Automated image processing for Django models.', long_description=read(os.path.join(os.path.dirname(__file__), 'README.rst')), - author='Justin Driscoll', - author_email='justin@driscolldev.com', + author='Matthew Tretter', + author_email='m@tthewwithanm.com', maintainer='Bryan Veloso', maintainer_email='bryan@revyver.com', license='BSD', - url='http://github.com/jdriscoll/django-imagekit/', + url='http://github.com/matthewwithanm/django-imagekit/', packages=find_packages(), zip_safe=False, include_package_data=True, diff --git a/tests/test_sourcegroups.py b/tests/test_sourcegroups.py index 12eed3b..c69b11f 100644 --- a/tests/test_sourcegroups.py +++ b/tests/test_sourcegroups.py @@ -32,7 +32,7 @@ def test_no_source_saved_signal(): Creating a new instance without an image shouldn't cause the source_saved signal to be dispatched. - https://github.com/jdriscoll/django-imagekit/issues/214 + https://github.com/matthewwithanm/django-imagekit/issues/214 """ source_group = ImageFieldSourceGroup(ImageModel, 'image') From d3882c34b29c651e0fb8611ac0141e075e5235f9 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Tue, 4 Jun 2013 21:36:31 -0400 Subject: [PATCH 3/9] Update installation directions; closes #223 --- README.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/README.rst b/README.rst index 53e8781..8a30efd 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,6 @@ Installation 1. Install `PIL`_ or `Pillow`_. (If you're using an ``ImageField`` in Django, you should have already done this.) 2. ``pip install django-imagekit`` - (or clone the source and put the imagekit module on your path) 3. Add ``'imagekit'`` to your ``INSTALLED_APPS`` list in your project's settings.py .. note:: If you've never seen Pillow before, it considers itself a From 6582794408af457d65c426e37c72fa6ec6dd4463 Mon Sep 17 00:00:00 2001 From: Jacob Magnusson Date: Tue, 14 May 2013 10:44:08 +0200 Subject: [PATCH 4/9] Remove unused imports --- tests/test_cachefiles.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_cachefiles.py b/tests/test_cachefiles.py index 957b132..3cd6af6 100644 --- a/tests/test_cachefiles.py +++ b/tests/test_cachefiles.py @@ -3,8 +3,6 @@ from hashlib import md5 from imagekit.cachefiles import ImageCacheFile from imagekit.cachefiles.backends import Simple from nose.tools import raises, eq_ -import random -import string from .imagegenerators import TestSpec from .utils import (assert_file_is_truthy, assert_file_is_falsy, DummyAsyncCacheFileBackend, get_unique_image_file) From 654867c3cf46ca8dcf21666dcb1d968d621eda0d Mon Sep 17 00:00:00 2001 From: Jacob Magnusson Date: Mon, 20 May 2013 11:22:59 +0200 Subject: [PATCH 5/9] PEP 3110 compat --- imagekit/management/commands/generateimages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagekit/management/commands/generateimages.py b/imagekit/management/commands/generateimages.py index 099fe3d..444440a 100644 --- a/imagekit/management/commands/generateimages.py +++ b/imagekit/management/commands/generateimages.py @@ -27,7 +27,7 @@ well as "a:b" and "a:b:c".""") try: # TODO: Allow other validation actions through command option file.generate() - except Exception, err: + except Exception as err: # TODO: How should we handle failures? Don't want to error, but should call it out more than this. self.stdout.write(' FAILED: %s\n' % err) From 3001069254a320fb3a2fa519dc61e14b329cc00f Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Tue, 4 Jun 2013 23:34:26 -0400 Subject: [PATCH 6/9] Test stringification of LazyImageCacheFiles --- tests/test_cachefiles.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/test_cachefiles.py b/tests/test_cachefiles.py index 3cd6af6..4338a82 100644 --- a/tests/test_cachefiles.py +++ b/tests/test_cachefiles.py @@ -1,11 +1,12 @@ from django.conf import settings from hashlib import md5 -from imagekit.cachefiles import ImageCacheFile +from imagekit.cachefiles import ImageCacheFile, LazyImageCacheFile from imagekit.cachefiles.backends import Simple from nose.tools import raises, eq_ from .imagegenerators import TestSpec from .utils import (assert_file_is_truthy, assert_file_is_falsy, - DummyAsyncCacheFileBackend, get_unique_image_file) + DummyAsyncCacheFileBackend, get_unique_image_file, + get_image_file) def test_no_source_falsiness(): @@ -73,3 +74,15 @@ def test_memcached_cache_key(): settings.IMAGEKIT_CACHE_PREFIX, '1' * (200 - len(':') - 32 - len(settings.IMAGEKIT_CACHE_PREFIX)), md5('%s%s-state' % (settings.IMAGEKIT_CACHE_PREFIX, filename)).hexdigest())) + + +def test_lazyfile_stringification(): + file = LazyImageCacheFile('testspec', source=None) + eq_(str(file), '') + eq_(repr(file), '') + + source_file = get_image_file() + file = LazyImageCacheFile('testspec', source=source_file) + file.name = 'a.jpg' + eq_(str(file), 'a.jpg') + eq_(repr(file), '') From 01a6c555a159fa4a88bba58bd1fb5b5721ec03e1 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Tue, 4 Jun 2013 23:33:09 -0400 Subject: [PATCH 7/9] Fix LazyImageCacheFile.__repr__ and __str__ Using SimpleLazyObject also lets us clean things up a bit. Closes #218 --- imagekit/cachefiles/__init__.py | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/imagekit/cachefiles/__init__.py b/imagekit/cachefiles/__init__.py index 7d8233a..2c602ff 100644 --- a/imagekit/cachefiles/__init__.py +++ b/imagekit/cachefiles/__init__.py @@ -1,7 +1,7 @@ from django.conf import settings from django.core.files import File from django.core.files.images import ImageFile -from django.utils.functional import LazyObject +from django.utils.functional import SimpleLazyObject from ..files import BaseIKFile from ..registry import generator_registry from ..signals import content_required, existence_required @@ -130,27 +130,12 @@ class ImageCacheFile(BaseIKFile, ImageFile): return self.cachefile_backend.exists(self) -class LazyImageCacheFile(LazyObject): +class LazyImageCacheFile(SimpleLazyObject): def __init__(self, generator_id, *args, **kwargs): - super(LazyImageCacheFile, self).__init__() - def setup(): generator = generator_registry.get(generator_id, *args, **kwargs) - self._wrapped = ImageCacheFile(generator) - - self.__dict__['_setup'] = setup + return ImageCacheFile(generator) + super(LazyImageCacheFile, self).__init__(setup) def __repr__(self): - if self._wrapped is None: - self._setup() - return '<%s: %s>' % (self.__class__.__name__, self or 'None') - - def __str__(self): - if self._wrapped is None: - self._setup() - return str(self._wrapped) - - def __unicode__(self): - if self._wrapped is None: - self._setup() - return unicode(self._wrapped) + return '<%s: %s>' % (self.__class__.__name__, str(self) or 'None') From bb7e9e58917a54e0982d4d343ed14895b3e9871c Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Mon, 10 Jun 2013 18:33:22 -0400 Subject: [PATCH 8/9] Fix cache backend fallback Closes #225 Closes #226 --- imagekit/conf.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/imagekit/conf.py b/imagekit/conf.py index 1edad95..2900da1 100644 --- a/imagekit/conf.py +++ b/imagekit/conf.py @@ -24,14 +24,19 @@ class ImageKitConf(AppConf): else: dummy_cache = 'django.core.cache.backends.dummy.DummyCache' + # DEFAULT_CACHE_ALIAS doesn't exist in Django<=1.2 + try: + from django.core.cache import DEFAULT_CACHE_ALIAS as default_cache_alias + except ImportError: + default_cache_alias = 'default' + if settings.DEBUG: value = dummy_cache + elif default_cache_alias in getattr(settings, 'CACHES', {}): + value = default_cache_alias else: - value = ( - getattr(settings, 'CACHES', {}).get('default') - or getattr(settings, 'CACHE_BACKEND', None) - or dummy_cache - ) + value = getattr(settings, 'CACHE_BACKEND', None) or dummy_cache + return value def configure_default_file_storage(self, value): From 90e9d314a61e7b95c317bba288d2fc0ac77b50ca Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Tue, 11 Jun 2013 14:08:23 -0700 Subject: [PATCH 9/9] Bump version to 3.0.1. --- imagekit/pkgmeta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagekit/pkgmeta.py b/imagekit/pkgmeta.py index e7813dd..feb0225 100644 --- a/imagekit/pkgmeta.py +++ b/imagekit/pkgmeta.py @@ -1,5 +1,5 @@ __title__ = 'django-imagekit' __author__ = 'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett, Matthew Tretter, Eric Eldredge' -__version__ = '3.0.0' +__version__ = '3.0.1' __license__ = 'BSD' __all__ = ['__title__', '__author__', '__version__', '__license__']