degal/folder.py
changeset 132 c2b2f4b6fe6d
parent 131 7021d949222c
child 133 0c1c092bbc5d
--- a/degal/folder.py	Wed Jun 17 17:02:24 2009 +0300
+++ b/degal/folder.py	Wed Jun 17 17:56:02 2009 +0300
@@ -131,6 +131,17 @@
         # and the last one
         if prev :
             yield prev
+    
+    @lazy_load
+    def empty (self) :
+        """
+            A Folder is empty if it does not contain any Images, and all of its sub-Folders (if any) are also empty.
+
+            This is implemented recursively.
+        """
+        
+        # simple logic, my dear friend Watson
+        return not self.images and all(subfolder.empty for subfolder in self.subfolders)
 
     @property
     def page_count (self) :