--- a/degal/image.py Mon Jun 15 01:42:45 2009 +0300
+++ b/degal/image.py Mon Jun 15 02:58:30 2009 +0300
@@ -2,7 +2,7 @@
Per-image gallery state
"""
-import filesystem, format, thumbnail, exif
+import filesystem, format, thumbnail, exif, utils
from utils import lazy_load
import PIL.Image
@@ -127,8 +127,6 @@
"""
Drop some memory-intensive cached values
"""
+
+ utils.unload(self, 'img', 'exif', 'metadata')
- del self.img
- del self.exif
- del self.metadata
-
--- a/degal/utils.py Mon Jun 15 01:42:45 2009 +0300
+++ b/degal/utils.py Mon Jun 15 02:58:30 2009 +0300
@@ -77,6 +77,15 @@
lazy_load = LazyProperty
lazy_load_iter = LazyIteratorProperty
+def unload (obj, *attrs) :
+ """
+ Un-load the named attributes from the given object.
+ """
+
+ for attr in attrs :
+ if attr in obj.__dict__ :
+ del obj.__dict__[attr]
+
def first (iterable) :
"""
Returns the first item from the iterable that evaluates to True, otherwise None.
@@ -86,7 +95,6 @@
>>> first("abc")
'a'
>>> first(('', list(), (), False))
- None
"""
for item in iterable :