changeset 3767:0b7f7b9226df

config: improve some lazy-loading code
author Johannes Berg <johannes AT sipsolutions DOT net>
date Sun, 22 Jun 2008 14:52:02 +0200
parents 6a618481be28
children b03223ab1818
files MoinMoin/config/multiconfig.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Sun Jun 22 12:23:59 2008 +0200
+++ b/MoinMoin/config/multiconfig.py	Sun Jun 22 14:52:02 2008 +0200
@@ -369,9 +369,10 @@
             self.computed_settings[k] = True
 
 
+    _meta_dict = None
     def load_meta_dict(self):
         """ The meta_dict contains meta data about the wiki instance. """
-        if getattr(self, "_meta_dict", None) is None:
+        if self._meta_dict is None:
             self._meta_dict = wikiutil.MetaDict(os.path.join(self.data_dir, 'meta'), self.cache_dir)
         return self._meta_dict
     meta_dict = property(load_meta_dict)
@@ -387,11 +388,12 @@
     iwid_full = make_iwid_property("_iwid_full")
 
     # lazily create a list of event handlers
+    _event_handlers = None
     def make_event_handlers_prop():
         def getter(self):
-            if getattr(self, "_event_handlers", None) is None:
+            if self._event_handlers is None:
                 self._event_handlers = events.get_handlers(self)
-            return getattr(self, "_event_handlers")
+            return self._event_handlers
 
         def setter(self, new_handlers):
             self._event_handlers = new_handlers