misc. stuff in gallery.py utils.py
authorTero Marttila <terom@fixme.fi>
Fri, 05 Jun 2009 23:06:06 +0300
changeset 73 8897352630a5
parent 72 168a2d065f17
child 74 3bf1adf13fdf
misc. stuff in gallery.py utils.py
degal/gallery.py
degal/utils.py
--- a/degal/gallery.py	Fri Jun 05 23:05:49 2009 +0300
+++ b/degal/gallery.py	Fri Jun 05 23:06:06 2009 +0300
@@ -28,8 +28,8 @@
             It will be created if it does not exist.
         """
 
-        return self.subdir('degal', create=True)
-
+        return self.subdir('.degal', create=True)
+    
     @lazy_load
     def stylesheet (self) :
         """
--- a/degal/utils.py	Fri Jun 05 23:05:49 2009 +0300
+++ b/degal/utils.py	Fri Jun 05 23:06:06 2009 +0300
@@ -18,35 +18,56 @@
 
         self.value = None
 
-    def run (self) :
+    def run (self, obj) :
         """
             Run the background func and return the to-be-cached value
         """
 
-        return super(LazyProperty, self).__call__()
+        return super(LazyProperty, self).__call__(obj)
+ 
+    def get (self, obj) :
+        """
+            Return the cached value
+        """
 
-    def __call__ (self) :
+        xxx
+    
+    def set (self, obj, value) :
+        """
+            Set the cached value
+        """
+
+        xxx
+
+    def test (self, obj) :
+        """
+            Tests if a value is set
+        """
+
+        xxx
+       
+    def __call__ (self, obj) :
         """
             Return the cached value if it exists, otherwise, call the func
         """
 
-        if not self.value :
+        if self.test(obj):
             # generate it
-            self.value = self.run()
+            self.set(obj, self.run(obj))
 
-        return self.value
+        return self.get(obj)
 
 class LazyIteratorProperty (LazyProperty) :
     """
         A lazy-loaded property that automatically converts an iterator/genexp into a list.
     """
 
-    def run (self) :
+    def run (self, obj) :
         """
             Wrap LazyProperty.run to return a list
         """
 
-        return list(super(LazyIteratorProperty, self).run())
+        return list(super(LazyIteratorProperty, self).run(obj))
 
 lazy_load = LazyProperty
 lazy_load_iter = LazyIteratorProperty