Compare commits

..

18 commits

Author SHA1 Message Date
Venelin Stoykov
097999f3cf Merge branch 'release/4.0.2'
* release/4.0.2:
  Bump version to 4.0.2
  Do not leak open files after generation
  Fix `ImageCacheFile.__repr__` to not send signals
  Make generateimages support pre Django 1.8 versions
  generateimages: fix taking arguments
  README - use Python 3 print function
  In Python 3 files should be opened as binary
  Fixed #368 use specs directly in ProcessedImageField
2017-11-20 10:28:47 +02:00
Venelin Stoykov
ef45747bf9 Merge branch 'release/4.0.1'
* release/4.0.1:
  stylling and linting fixes to setup.py
  Bump version to 4.0.1
  Cleaned up _autodiscovered flag handling.
  Added huge performance improvement by running imagekit.utils.autodiscover() only once on Django > 1.7 as it was intended.
  Update README.st change model->instance for clarity in defining specs outside of models.
  Improved docs to include example on how to use plain ImageSpec (defined outside of model, not ImageSpecField) with AdminThumbnail.
2017-05-17 18:14:18 +03:00
Venelin Stoykov
acefa913f9 Merge pull request #415 from tyagow/patch-1
Update advanced_usage.rst
2017-04-24 18:20:31 +03:00
Tiago Almeida
33a62b8840 Update advanced_usage.rst
wrong attribute access... probally miss typed..
thumbnail dosent exists so i think its mode.thumbnail_height
2017-04-23 16:25:13 -03:00
Venelin Stoykov
f724cb0118 Merge branch 'release/4.0'
* release/4.0:
  Bump version to 4.0
  Universal wheels!
  Replaces #301 autodiscover works with AppConfig
  Ignore autogenerated CTags file
  Do not try south modelinspector when not needed
  Make it possible to configure IMAGEKIT_CACHE_TIMEOUT
  Test against Django 1.11
  Close the file only if it has been opened locally
  Cleanup caching configuration
  updated readme.rst with a svg badge
  honor post_save's update_fields and only fire the source_saved signal when needed
  Ignore VSCode workspace config files
  Fixed #350: Error when trying to access width/height after url
  Fixes #382: Tests no longer leave junk
  Fixes #379 Support for Django 1.10
  Ignore .idea from git
  Include the test suite in the sourcetarball but do not install it.
  Make travis happy
  Drop support for older Django and Python versions
  Replace Lenna image in tests with a truly free alternative.
  Move compat module outside of templatetags package
  Fix test requirements for django 1.9 and Python3.5
2017-02-22 15:54:07 +02:00
Bryan Veloso
bc93ec2920 Merge branch 'release/3.3'
* release/3.3:
  Add @vstoykov to the author list.
  Bump version number.
  Update django-nose version to work with Django 1.9
  Add a missing env to the tox matrix
  Work a compatibility implementation for Django 1.2
  Tells tox to only run the designated env
  Enable the new travis architecture for speed and reliability
  Allow the test to fail fast
  Allow travis to fail for the python3.5 interpreter not yet available
  Use the env conf for travis to split the test builds
  Add tox env for django 1.9
  Update the doc to reflect the new `IMAGEKIT_CACHE_BACKEND` behavior
  Cleaner implementation thanks to @vstoykov explanation
  Handle cases where DEFAULT_CACHE_ALIAS is None in old Django versions
  Do not take a decision on which cache to use in DEBUG mode
  Use a compat method to wrap the new way of retrieving the cache engine
2015-12-08 11:41:23 -08:00
Bryan Veloso
96f0b5da4d Merge branch 'release/3.2.7'
* release/3.2.7:
  Bump the version to 3.2.7.
  Fixes open cache file never getting closed
  Fixes open source file never getting closed
  Do not use progressive when we are not running in terminal
  Add test environments for Python3.4 and Django1.7 and Django1.8
  Fixes imports in README example for ProcessedImageField
2015-08-23 18:02:32 -07:00
Bryan Veloso
b398c2cee4 Merge branch 'release/3.2.6'
* release/3.2.6:
  Bump the version to 3.2.6.
  Updated importlib import to fix DeprecationWarning (for django 1.8)
  Add note about usage of optimistic strategy with async backend
  Fix typo
2015-02-26 10:28:51 -08:00
Bryan Veloso
2bcb93da22 Merge branch 'release/3.2.5'
* release/3.2.5:
  Bump the version to 3.2.5.
  Explicitly setting serializer for celery task
2015-01-05 15:58:47 -08:00
Bryan Veloso
00b4095e40 Merge branch 'release/3.2.4'
* release/3.2.4:
  Bump the version to 3.2.4.
  Deprecate `imagekit.processors` submodules
  Catch autodiscover module import error
2014-09-28 13:23:46 -07:00
Bryan Veloso
bc0b0a8a75 Merge branch 'release/3.2.3'
* release/3.2.3:
  Bump the version to 3.2.3.
  Exclude tests from dist
  Revert "Remove test dir __init__.py"
  Only include fetched fields in initial hash of sources
  Add test to illustrate GH-295
  Test that there isn't IO done when you get a URL
  Support should_verify_existence on strategies
  Test that Optimistic strategy doesn't cause reads
  Ignore my Python3 virtualenv
  Remove test dir __init__.py
  Fixed minor spelling error in README.rst
2014-09-27 22:21:17 -07:00
Bryan Veloso
b176c0cafe Merge branch 'release/3.2.2'
* release/3.2.2:
  Bump version to 3.2.2.
  Make sure image files has a name associated.
2014-07-14 12:24:13 -07:00
Bryan Veloso
9f69d7e056 Merge branch 'release/3.2.1'
* release/3.2.1:
  Bump the version to 3.2.1.
  Simplified RQ cache file backed by using the job decorator
  Add note about `open()`
  Always call variable "source_file"
  setup.py: added 'async_rq' extra, django-rq dependency
  Removed unneeded django_rq import
  Added a DeprecationWarning if Async cache file backend is used
  Updated tox.ini to test against Django 1.6.
  Fixed #266 -- Simplified (and renamed) StrategyWrapper.
  Link to Instakit.
2014-04-04 09:27:30 -07:00
Bryan Veloso
ab3593ed54 Merge branch 'release/3.2'
* release/3.2:
  Bump the version to 3.2.
  Use signal.connect for backwards compat
  Add Venelin Stoykov to AUTHORS
  Improve logic of contributing ImageSpecFields to Models
  Use force_bytes from imagekit.lib in test_cachefiles
  Remove @vstoykov's note. Seems like the right place to me (:
  Move force_bytes into lib module
  Don't use a raw string with \u escapes
  Fix sanitizing cache key under Python 3
  Add module to sys.modules
  Test for Python 3
  Insert importer at beginning of list
  Delay Django import until needed
  Add Python 3 suport and drop support for Python 2.5
2014-01-01 15:18:38 -08:00
Bryan Veloso
a14fc91c8d Merge branch 'release/3.1'
* release/3.1:
  Tagging 3.1.
  Correct reference to generateimage tag
  Fix celery backend
  Cache file backends: dropped the "Async" in class names
  Added RQ-based async cache file backend
2013-12-20 09:19:40 -08:00
Bryan Veloso
6929128180 Merge branch 'release/3.0.4'
* release/3.0.4:
  Bump the version to 3.0.4.
  Add __getstate__ method to ImageCacheFile
  Update IMAGEKIT_DEFAULT_FILE_STORAGE description
  Discover image generators during lookup
  Added global boolean to prevent autodiscover() from being called more than once.
  Update fields.py
  Run tests with Django 1.5
2013-09-26 10:56:30 -07:00
Bryan Veloso
a9a152cdfa Merge branch 'release/3.0.3'
* release/3.0.3:
  Bump to 3.0.3.
  Woops. It uses the cache if DEBUG is False.
  Remove PENDING state
2013-07-22 10:01:26 -07:00
Bryan Veloso
31eab7666a Merge branch 'release/3.0.2'
* release/3.0.2:
  Removing the changelog. Changelogs are hard.
  Bump to 3.0.2.
  Use == for comparison
  Don't mutate __dict__
  Don't require source in __setstate__; fixes #234
  Add (failing) test for #234
  Don't include cache in serialization of backend
  Fixed name of spec id attr
2013-07-17 11:46:07 -07:00
17 changed files with 206 additions and 78 deletions

View file

@ -1,35 +1,62 @@
sudo: false
language: python
python:
- "3.8"
- "3.7"
- "3.6"
- "3.5"
env:
- DJANGO="master"
- DJANGO="30"
- DJANGO="22"
- DJANGO="21"
- DJANGO="21"
- DJANGO="20"
- DJANGO="111"
sudo: false
install:
- pip install tox
script:
- tox -e py$(python -c 'import sys;print("".join(map(str, sys.version_info[:2])))')-django${DJANGO}
- tox
jobs:
matrix:
fast_finish: true
allow_failures:
- env: DJANGO="master"
exclude:
- python: "3.5"
env: DJANGO="30"
- python: "3.5"
env: DJANGO="master"
include:
- env: TOXENV=py27-django14
python: 2.7
- env: TOXENV=py27-django15
python: 2.7
- env: TOXENV=py27-django16
python: 2.7
- env: TOXENV=py27-django17
python: 2.7
- env: TOXENV=py27-django18
python: 2.7
- env: TOXENV=py27-django19
python: 2.7
- env: TOXENV=py27-django110
python: 2.7
- env: TOXENV=py27-django111
python: 2.7
- env: TOXENV=py33-django15
python: 3.3
- env: TOXENV=py33-django16
python: 3.3
- env: TOXENV=py33-django17
python: 3.3
- env: TOXENV=py33-django18
python: 3.3
- env: TOXENV=py34-django16
python: 3.4
- env: TOXENV=py34-django17
python: 3.4
- env: TOXENV=py34-django18
python: 3.4
- env: TOXENV=py34-django19
python: 3.4
- env: TOXENV=py34-django110
python: 3.4
- env: TOXENV=py34-django111
python: 3.4
- env: TOXENV=py35-django18
python: 3.5
- env: TOXENV=py35-django19
python: 3.5
- env: TOXENV=py35-django110
python: 3.5
- env: TOXENV=py35-django111
python: 3.5
notifications:
irc: "irc.freenode.org#imagekit"

View file

@ -39,7 +39,6 @@ Installation
Usage Overview
==============
.. _specs:
Specs
-----

View file

@ -90,7 +90,7 @@ for getting this information.
@property
def processors(self):
model, field_name = get_field_info(self.source)
return [ResizeToFill(model.thumbnail_width, thumbnail.avatar_height)]
return [ResizeToFill(model.thumbnail_width, model.thumbnail_height)]
register.generator('myapp:profile:avatar_thumbnail', AvatarThumbnail)

View file

@ -3,7 +3,7 @@ Caching
Default Backend Workflow
========================
================
``ImageSpec``
@ -29,8 +29,6 @@ objects, but they've got a little trick up their sleeve: they represent files
that may not actually exist!
.. _cache-file-strategy:
Cache File Strategy
-------------------
@ -57,8 +55,6 @@ The default strategy only defines the first two of these, as follows:
file.generate()
.. _cache-file-backend:
Cache File Backend
------------------
@ -189,11 +185,6 @@ Or, in Python:
def on_source_saved(self, file):
file.generate()
.. note::
If you use custom storage backend for some specs,
(storage passed to the field different than configured one)
it's required the storage to be pickleable
__ https://pypi.python.org/pypi/django-celery

View file

@ -54,7 +54,7 @@ execfile(os.path.join(os.path.dirname(__file__), '..', 'imagekit',
# built documents.
#
# The short X.Y version.
version = re.match(r'\d+\.\d+', pkgmeta['__version__']).group()
version = re.match('\d+\.\d+', pkgmeta['__version__']).group()
# The full version, including alpha/beta/rc tags.
release = pkgmeta['__version__']

View file

@ -79,9 +79,12 @@ IK3 provides analogous settings for cache file backends and strategies:
IMAGEKIT_DEFAULT_CACHEFILE_BACKEND = 'path.to.MyCacheFileBackend'
IMAGEKIT_DEFAULT_CACHEFILE_STRATEGY = 'path.to.MyCacheFileStrategy'
See the documentation on :ref:`cache file backends <cache-file-backend>` and :ref:`cache file strategies <cache-file-strategy>`
See the documentation on `cache file backends`_ and `cache file strategies`_
for more details.
.. _`cache file backends`:
.. _`cache file strategies`:
Conditional model ``processors``
--------------------------------
@ -90,7 +93,9 @@ In IK2, an ``ImageSpecField`` could take a ``processors`` callable instead of
an iterable, which allowed processing decisions to made based on other
properties of the model. IK3 does away with this feature for consistency's sake
(if one kwarg could be callable, why not all?), but provides a much more robust
solution: the custom ``spec``. See the :doc:`advanced usage <advanced_usage>` documentation for more.
solution: the custom ``spec``. See the `advanced usage`_ documentation for more.
.. _`advanced usage`:
Conditonal ``cache_to`` file names
@ -104,7 +109,9 @@ There is a way to achieve custom file names by overriding your spec's
``cachefile_name``, but it is not recommended, as the spec's default
behavior is to hash the combination of ``source``, ``processors``, ``format``,
and other spec options to ensure that changes to the spec always result in
unique file names. See the documentation on :ref:`specs` for more.
unique file names. See the documentation on `specs`_ for more.
.. _`specs`:
Processors have moved to PILKit

View file

@ -144,24 +144,8 @@ class ImageCacheFile(BaseIKFile, ImageFile):
# file is hidden link to "file" attribute
state.pop('_file', None)
# remove storage from state as some non-FileSystemStorage can't be
# pickled
settings_storage = get_singleton(
settings.IMAGEKIT_DEFAULT_FILE_STORAGE,
'file storage backend'
)
if state['storage'] == settings_storage:
state.pop('storage')
return state
def __setstate__(self, state):
if 'storage' not in state:
state['storage'] = get_singleton(
settings.IMAGEKIT_DEFAULT_FILE_STORAGE,
'file storage backend'
)
self.__dict__.update(state)
def __nonzero__(self):
# Python 2 compatibility
return self.__bool__()

View file

@ -110,7 +110,7 @@ class Simple(CachedFileBackend):
def _exists(self, file):
return bool(getattr(file, '_file', None)
or (file.name and file.storage.exists(file.name)))
or file.storage.exists(file.name))
def _generate_file(backend, file, force=False):

View file

@ -49,7 +49,7 @@ class BaseIKFile(File):
def _get_size(self):
self._require_file()
if not getattr(self, '_committed', False):
if not self._committed:
return self.file.size
return self.storage.size(self.name)
size = property(_get_size)

View file

@ -1,4 +1,4 @@
from unittest import mock
import mock
from django.conf import settings
from hashlib import md5
from imagekit.cachefiles import ImageCacheFile, LazyImageCacheFile

View file

@ -30,7 +30,7 @@ def test_dangling_html_attrs_delimiter():
@raises(TemplateSyntaxError)
def test_html_attrs_assignment():
"""
You can either use generateimage as an assignment tag or specify html attrs,
You can either use generateimage as an assigment tag or specify html attrs,
but not both.
"""

View file

@ -1,5 +1,5 @@
from nose.tools import assert_false
from unittest.mock import Mock, PropertyMock, patch
from mock import Mock, PropertyMock, patch
from .models import Photo

View file

@ -1,6 +1,6 @@
from nose.tools import assert_true, assert_false
from imagekit.cachefiles import ImageCacheFile
from unittest.mock import Mock
from mock import Mock
from .utils import create_image
from django.core.files.storage import FileSystemStorage
from imagekit.cachefiles.backends import Simple as SimpleCFBackend

View file

@ -37,7 +37,4 @@ def test_cachefiles():
# remove link to file from spec source generator
# test __getstate__ of ImageCacheFile
file.generator.source = None
restored_file = pickleback(file)
assert file is not restored_file
# Assertion for #437 and #451
assert file.storage is restored_file.storage
pickleback(file)

View file

@ -42,7 +42,7 @@ def test_too_many_args():
@raises(TemplateSyntaxError)
def test_html_attrs_assignment():
"""
You can either use thumbnail as an assignment tag or specify html attrs,
You can either use thumbnail as an assigment tag or specify html attrs,
but not both.
"""

View file

@ -64,7 +64,7 @@ def render_tag(ttag):
def get_html_attrs(ttag):
return BeautifulSoup(render_tag(ttag), features="html.parser").img.attrs
return BeautifulSoup(render_tag(ttag)).img.attrs
def assert_file_is_falsy(file):

145
tox.ini
View file

@ -1,18 +1,141 @@
[tox]
envlist =
py38-django{master,30,22,21,20,111},
py37-django{master,30,22,21,20,111},
py36-django{master,30,22,21,20,111},
py35-django{21,20,111},
py35-django111, py35-django110, py35-django19, py35-django18,
py34-django111, py34-django110, py34-django19, py34-django18, py34-django17, py34-django16,
py33-django18, py33-django17, py33-django16, py33-django15,
py27-django111, py27-django110, py27-django19, py27-django18, py27-django17, py27-django16, py27-django15, py27-django14,
[testenv]
commands = python setup.py test
[testenv:py35-django111]
basepython = python3.5
deps =
djangomaster: git+https://github.com/django/django.git@master#egg=Django
django30: Django>=3.0,<3.1
django22: Django>=2.2,<3.0
django21: Django>=2.1,<2.2
django20: Django>=2.0,<2.1
django111: Django>=1.11,<2.0
django{21,20,111}: django-nose==1.4.5
Django>=1.11a1,<1.12
django-nose==1.4.4
[testenv:py35-django110]
basepython = python3.5
deps =
Django>=1.10,<1.11
django-nose==1.4.4
[testenv:py35-django19]
basepython = python3.5
deps =
Django>=1.9,<1.10
django-nose==1.4.2
[testenv:py35-django18]
basepython = python3.5
deps =
Django>=1.8,<1.9
django-nose==1.4.2
[testenv:py34-django111]
basepython = python3.4
deps =
Django>=1.11a1,<1.12
django-nose==1.4.4
[testenv:py34-django110]
basepython = python3.4
deps =
Django>=1.10,<1.11
django-nose==1.4.4
[testenv:py34-django19]
basepython = python3.4
deps =
Django>=1.9,<1.10
django-nose==1.4.2
[testenv:py34-django18]
basepython = python3.4
deps =
Django>=1.8,<1.9
django-nose==1.4.2
[testenv:py34-django17]
basepython = python3.4
deps =
Django>=1.7,<1.8
django-nose==1.4
[testenv:py34-django16]
basepython = python3.4
deps =
Django>=1.6,<1.7
django-nose<=1.4.2
[testenv:py33-django18]
basepython = python3.3
deps =
Django>=1.8,<1.9
django-nose==1.4.2
[testenv:py33-django17]
basepython = python3.3
deps =
Django>=1.7,<1.8
django-nose==1.4
[testenv:py33-django16]
basepython = python3.3
deps =
Django>=1.6,<1.7
django-nose<=1.4.2
[testenv:py33-django15]
basepython = python3.3
deps =
Django>=1.5,<1.6
django-nose==1.4
[testenv:py27-django111]
basepython = python2.7
deps =
Django>=1.11a1,<1.12
django-nose==1.4.4
[testenv:py27-django110]
basepython = python2.7
deps =
Django>=1.10,<1.11
django-nose==1.4.4
[testenv:py27-django19]
basepython = python2.7
deps =
Django>=1.9,<1.10
django-nose==1.4.2
[testenv:py27-django18]
basepython = python2.7
deps =
Django>=1.8,<1.9
django-nose==1.4.2
[testenv:py27-django17]
basepython = python2.7
deps =
Django>=1.7,<1.8
django-nose==1.4
[testenv:py27-django16]
basepython = python2.7
deps =
Django>=1.6,<1.7
django-nose<=1.4.2
[testenv:py27-django15]
basepython = python2.7
deps =
Django>=1.5,<1.6
django-nose==1.4
[testenv:py27-django14]
basepython = python2.7
deps =
Django>=1.4,<1.5
django-nose==1.4