first pickle, then save to avoid killing config file on sigint
[enigma2.git] / lib / python / Components / Element.py
index 437d934bb507529969571bdeaa487c1503dc825e..509a1c8dd37985f4b5822a1c2750e76277aab79d 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.msg = message
+
+    def __str__(self):
+        return self.msg
+
 class Element(object):
        CHANGED_DEFAULT = 0   # initial "pull" state
        CHANGED_ALL = 1       # really everything changed