SmileyChris/easy-thumbnails — pull request #179 by roberts81 (2012-11-21 21:07:33+00:00)
Title: Utilize the modified_time function implemented by Storage classes instead of assuming thumbnail storages are path-based and manually using os.path to calculate mod times

Currently, get_source_modtime & get_thumbnail_modtime, in files.py (line 461 & 470), is hardcoded to use os.path.getmtime(path) to get the modtimes for thumbnails and sources. As you're aware, modtimes are critical for the thumbnail_exists method(and much of the framework) to operate correctly.

I've written a database-based storage backend & a memcached storage backend (with fall back to database) in order to do various things on Heroku, which has an ephemeral file-system that is useless for writes.

As it stands, easy-thumbnails trunk doesn't work with these backends because of the mod time issue. However, there was no reason why it couldn't work if the storage backend's implemented the modified_time interface which Django's Storage prescribes. FileSystemStorage (and by extension ThumbnailFileSystemStorage) already implement modified_time by doing basically the same thing easy-thumbnails manually does:

```
def modified_time(self, name):
return datetime.fromtimestamp(os.path.getmtime(self.path(name)))
```
In sum, it seems more correct to use the storage's modified_time method rather than manually getting the modified time, and this enables different types of backends.

My fork swaps out the hardcoded called to os.path and calls the storage's modified_time method instead. Also, the code```update_modified = modtime and utils.fromtimestamp``` at lines 437 and 449 is simplified to just use modtime, since the modified_time method in FileSystemStorage performs this already.

All tests pass, and I don't really see room for new tests beyond the current one, since this is using the modified_time method of Django Storage or FileSystemStorage (or of a custom storage) which are tested in their respective packages. But i'd be happy to write a test if you can describe to me what it would do.