Commit graph

78 commits

Author SHA1 Message Date
Venelin Stoykov
6ee931398f Do not leak open files after generation 2017-11-17 18:37:54 +02:00
rohit suri
732f7045e4 Close the file only if it has been opened locally 2017-02-15 21:24:32 -08:00
Igor
eb81b9c88c Fixes open source file never getting closed
In a processes that generates many images, you could run into a
cituation with too man files being open. This results in:
IOError: [Errno 24] Too many open files
2015-08-02 00:01:30 -07:00
Baptiste Mispelon
3799f3c2f4 Fixed #266 -- Simplified (and renamed) StrategyWrapper.
StrategyWrapper was unnecessarily implemented as a LazyObject
and it triggered a bug in Django (issue 21840).

Changing the lazy object to a function works just as well and
bypasses the bug.
2014-01-21 17:46:19 +01:00
Matthew Tretter
14939faef6 Don't mutate __dict__ 2013-07-13 17:13:58 -04:00
Matthew Tretter
3c04cb852f Don't require source in __setstate__; fixes #234 2013-07-13 17:12:55 -04:00
Matthew Tretter
4efa05099d Use pilkit's process_image utility 2013-05-09 22:02:03 -04:00
Matthew Tretter
f5b171979b Canonicalize sets and dicts before hashing 2013-04-25 02:30:37 -04:00
danxshap
13c92db760 Re-open source file on ValueError in ImageSpec.generate() 2013-04-21 16:06:13 -04:00
Matthew Tretter
6f9f99e86c Fields shouldn't cause AlreadyRegistered exceptions 2013-04-05 15:28:36 -04:00
Matthew Tretter
dafebc9a4d Don't call register without spec 2013-04-05 14:38:29 -04:00
Matthew Tretter
92a3c2688c Error when attempting to generate image w/o source 2013-02-25 22:42:47 -05:00
Matthew Tretter
b33869a9f8 Sourceless specs are falsy
Passes test added in 190153d. Related to #187
2013-02-25 22:18:33 -05:00
Matthew Tretter
301adc2087 Let's call em cachefiles
Changed my mind about 04aa72c1f9. It's
just a better description, even if different strategies can change the
behavior so it isn't really very cache-like.
2013-02-04 19:52:38 -05:00
Matthew Tretter
218f569005 Don't assign processors, so properties will work
This way, a subclass can add a @property without a setter and not worry
about an error.
2013-02-02 19:21:32 -05:00
Matthew Tretter
e1c819e9b4 Allow default generatedfile name configuration w/namers 2013-01-31 22:37:09 -05:00
Matthew Tretter
d6b73b8da7 Renaming/repackaging of generated file related classes 2013-01-31 19:24:08 -05:00
Matthew Tretter
04aa72c1f9 Rename cache things (it isn't cachine)
https://twitter.com/alex_gaynor/statuses/257558176965206016
2013-01-31 10:07:20 -05:00
Matthew Tretter
3931b552a0 Separate source groups and cacheables.
This allows a sensible specialized interface for source groups, but also
for ImageKit to interact with specs using the generalized image
generator interface.
2013-01-29 01:40:00 -05:00
Matthew Tretter
cef3a41d86 Merge branch 'ik-next' into cacheables
Conflicts:
	imagekit/management/commands/warmimagecache.py
	imagekit/registry.py
2013-01-28 21:45:37 -05:00
Eric Eldredge
a8855d4c27 Change spec/source registry to generator/cacheable 2013-01-23 22:46:57 -05:00
Matthew Tretter
4737ac64c4 Specs no longer accept arbitrary kwargs
Only the source.
2013-01-23 21:35:38 -05:00
Matthew Tretter
6ff1d35fbe Remove unused import 2013-01-23 21:31:53 -05:00
Matthew Tretter
eef1e41448 Remove code that used old filename kwarg 2013-01-23 21:28:23 -05:00
Matthew Tretter
4ecfa5d35e Don't rely on source filename being relative path
Closes #180
2013-01-13 23:40:26 -05:00
Matthew Tretter
658bb22c78 Special case serialization of ImageFieldFiles
Closes #168
2013-01-08 21:52:56 -05:00
Matthew Tretter
c2dedaa2b8 Use file name; not file, which can't be pickled 2013-01-08 20:57:19 -05:00
Matthew Tretter
d80f2f26a9 "source" now refers to the file itself 2012-12-11 22:53:13 -05:00
Matthew Tretter
8c80ba3b4f GeneratedImageCacheFile stores file manipulation attributes
Everything for dealing with files should be part of
GeneratedImageCacheFile--not the generator. The fact that
GeneratedImageCacheFile can get this information (storage, filename,
etc.) is a convenience so that the user only has to define one class
(the generator) to fully specify their functionality, but handling the
cache file is not part of the core responsibility of the generator.

This is also the reason for the renaming of `get_filename` and `storage`
to `cache_file_name` and `cache_file_storage`: the generator is just as
useful for those who want to generate persistent files. But the original
attribute names didn't indicate that they were used only for cache
files. The new ones do, and don't preclude the addition of other
versions that would be used by another `File` subclass for specifying
file names or storage classes.
2012-12-06 19:54:26 -05:00
Matthew Tretter
12307c97aa Use state--not constructor args--to recreate dynamic specs
Previously, we were relying on `__init__`'s arguments to recreate specs.
Now we do it the proper way, using the dict returned by `__getstate__`
(which may or may not include those arguments).
2012-12-05 23:51:30 -05:00
Matthew Tretter
042bdcefb6 Simplify dynamic spec definitions
Use a closure instead of an attribute to store the class attrs.
2012-12-05 23:38:10 -05:00
Matthew Tretter
2a6199b804 Simplify get_hash implementation 2012-12-05 23:16:07 -05:00
Matthew Tretter
0ec6067c8d Correct pickling/unpickling of dynamic specs
Previously, __reduce__ was returning a reduction of the class, not the
instance.
2012-12-05 21:10:36 -05:00
Matthew Tretter
7f11f44c67 Special case source_file for specs
It was already special. Why hide it? Closes #173
2012-12-05 21:10:31 -05:00
Matthew Tretter
956601b5d0 Revert register.spec argument order
Since we got rid of inner Config classes, we can put the order back and
support decorators.
2012-12-05 21:09:10 -05:00
Matthew Tretter
848d7d7fa3 Add TODOs 2012-12-01 23:19:45 -05:00
Matthew Tretter
14d2193f8d Remove unused args 2012-12-01 22:23:25 -05:00
Matthew Tretter
236eea8459 Move filename generation to generator 2012-12-01 22:09:34 -05:00
Matthew Tretter
7bc82d3624 Remove arguments from generate() method
Previously, we had two places where we were passing kwargs that affected
the image generation: the ImageSpec constructor and the generate method.
These were essentially partial applications. With this commit, there's
only one partial application (when the spec is instantiated), and the
generate method is called without arguments. Therefore, specs can now
be treated as generic generators whose constructors just happen to
accept a source_file.
2012-12-01 21:20:33 -05:00
Matthew Tretter
1f06c9ac70 Remove ImageSpecCacheFile 2012-12-01 20:41:08 -05:00
Eric Eldredge
e0567e8fa7 Remove specs.SpecRegistry; add registry module
The registry module splits the work that specs.SpecRegistry
used to do into two classes: GeneratorRegistry and
SourceGroupRegistry. These two registries are wrapped in
Register and Unregister utilities for API convenience.
2012-12-01 17:16:09 -05:00
Matthew Tretter
4ead0b3002 Add note about nested config classes 2012-12-01 15:51:40 -05:00
Matthew Tretter
5b1c5f7b4e Rename source objects to source groups 2012-12-01 15:51:28 -05:00
Matthew Tretter
49a55d4763 Try adding __reduce__ 2012-12-01 14:11:04 -05:00
Matthew Tretter
5a414a3644 Rename spec_args to spec_attrs 2012-11-06 23:50:23 -05:00
Matthew Tretter
f9e2ce8649 Add TODO 2012-11-03 00:27:03 -04:00
Matthew Tretter
5494ee7fc1 Clarify relationship between BaseImageSpec and ImageSpec 2012-11-03 00:08:47 -04:00
Matthew Tretter
64d95768f8 Extract GeneratedImageCacheFile
As mentioned in #167, we want to be forward thinking and allow for a
hypothetical spec supertype which has the same functionality as an image
spec but doesn't require a source file: a generator. To this end, I've
renamed `ImageSpec.apply()` to `ImageSpec.generate()` and extracted
a `GeneratedImageCacheFile` base class from `ImageSpecCacheFile`, which
supports the more general interface of a generator--namely, a
`generate()` method with arbitrary args and kwargs.
2012-11-02 00:33:33 -04:00
Matthew Tretter
570e7bd640 Simplify SpecHost creation 2012-10-25 22:31:37 -04:00
Matthew Tretter
76b9ebbab4 Omit missing kwargs so as not to override defaults
The default image cache strategy was being overridden, which prevented
images from being generated.
2012-10-25 22:25:18 -04:00