also check devidex2 here
[enigma2.git] / lib / python / Components / Element.py
index baab4cfb46d30284be8d3836d61e346e49a8b5bf..f4a8f1275d346d88b990690a696bf5b179b833b5 100644 (file)
@@ -8,13 +8,21 @@ from Tools.CList import CList
 def cached(f):
        name = f.__name__
        def wrapper(self):
-               if self.cache is None:
+               cache = self.cache
+               if cache is None:
                        return f(self)
-               if name not in self.cache:
-                       self.cache[name] = (True, f(self))
-               return self.cache[name][1]
+               if name not in cache:
+                       cache[name] = (True, f(self))
+               return cache[name][1]
        return wrapper
 
+class ElementError(Exception):
+    def __init__(self, message):
+        self.message = message
+
+    def __str__(self):
+        return self.message
+
 class Element(object):
        CHANGED_DEFAULT = 0   # initial "pull" state
        CHANGED_ALL = 1       # really everything changed
@@ -48,11 +56,13 @@ class Element(object):
                # we should not disconnect from upstream if
                # there are still elements depending on us.
                assert len(self.downstream_elements) == 0, "there are still downstream elements left"
-               
+
                # Sources don't have a source themselves. don't do anything here.
                if self.source is not None:
                        self.source.disconnectDownstream(self)
-       
+                       # sources are owned by the Screen, so don't destroy them here.
+                       self.destroy()
+
        def disconnectDownstream(self, downstream):
                self.downstream_elements.remove(downstream)
                if self.master == downstream:
@@ -89,3 +99,6 @@ class Element(object):
 
        def doSuspend(self, suspend):
                pass
+
+       def destroy(self):
+               pass