From c48c720f8a7cfda47c46b38004d80921ab2ea305 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Fri, 15 Mar 2013 00:27:23 -0400 Subject: [PATCH] Add __nonzero__ method that will work for async --- imagekit/cachefiles/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/imagekit/cachefiles/__init__.py b/imagekit/cachefiles/__init__.py index 24a77e3..c53a5ef 100644 --- a/imagekit/cachefiles/__init__.py +++ b/imagekit/cachefiles/__init__.py @@ -75,6 +75,15 @@ class ImageCacheFile(BaseIKFile, ImageFile): ) ) + def __nonzero__(self): + if not self.name: + return False + + # Dispatch the before_access signal before checking to see if the file + # exists. This gives the strategy a chance to create the file. + before_access.send(sender=self, file=self) + return self.cachefile_backend.exists(self) + class LazyImageCacheFile(LazyObject): def __init__(self, generator_id, *args, **kwargs):