mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-17 05:40:25 +00:00
Merge branch 'release/3.0.1'
* release/3.0.1: Bump version to 3.0.1. Fix cache backend fallback Fix LazyImageCacheFile.__repr__ and __str__ Test stringification of LazyImageCacheFiles PEP 3110 compat Remove unused imports Update installation directions; closes #223 I, for one, welcome our new @matthewwithanm overlords. Add import to example
This commit is contained in:
commit
ef05e23b66
12 changed files with 47 additions and 47 deletions
2
AUTHORS
2
AUTHORS
|
|
@ -6,8 +6,8 @@ HZDG_.
|
|||
Maintainers
|
||||
-----------
|
||||
|
||||
* `Bryan Veloso`_
|
||||
* `Matthew Tretter`_
|
||||
* `Bryan Veloso`_
|
||||
* `Chris Drackett`_
|
||||
* `Greg Newman`_
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
15
README.rst
15
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
|
||||
|
|
@ -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
|
||||
|
|
@ -177,7 +176,7 @@ to register it.
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
from imagekit import ImageSpec
|
||||
from imagekit import ImageSpec, register
|
||||
from imagekit.processors import ResizeToFill
|
||||
|
||||
class Thumbnail(ImageSpec):
|
||||
|
|
@ -371,7 +370,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 +413,7 @@ of generator ids in order to generate images selectively.
|
|||
Community
|
||||
=========
|
||||
|
||||
Please use `the GitHub issue tracker <https://github.com/jdriscoll/django-imagekit/issues>`_
|
||||
Please use `the GitHub issue tracker <https://github.com/matthewwithanm/django-imagekit/issues>`_
|
||||
to report bugs with django-imagekit. `A mailing list <https://groups.google.com/forum/#!forum/django-imagekit>`_
|
||||
also exists to discuss the project and ask questions, as well as the official
|
||||
`#imagekit <irc://irc.freenode.net/imagekit>`_ channel on Freenode.
|
||||
|
|
@ -436,5 +435,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
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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__']
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
"""
|
||||
|
|
|
|||
6
setup.py
6
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,
|
||||
|
|
|
|||
|
|
@ -1,13 +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_
|
||||
import random
|
||||
import string
|
||||
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():
|
||||
|
|
@ -75,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), '<ImageCacheFile: None>')
|
||||
|
||||
source_file = get_image_file()
|
||||
file = LazyImageCacheFile('testspec', source=source_file)
|
||||
file.name = 'a.jpg'
|
||||
eq_(str(file), 'a.jpg')
|
||||
eq_(repr(file), '<ImageCacheFile: a.jpg>')
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue