changeset 869:1a7aa271851d storage-ng

refactor indexing revision lazy retrieval
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 25 Sep 2011 16:55:28 +0200
parents 8cf8ea7431ca
children 04cdc3823cac
files MoinMoin/storage/middleware/indexing.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/storage/middleware/indexing.py	Sun Sep 25 16:41:58 2011 +0200
+++ b/MoinMoin/storage/middleware/indexing.py	Sun Sep 25 16:55:28 2011 +0200
@@ -757,12 +757,16 @@
     def name(self):
         return self.meta.get(NAME, 'DoesNotExist')
 
+    def _load(self):
+        meta, data = self.backend.retrieve(self.revid) # raises KeyError if rev does not exist
+        self.meta = Meta(self, self._doc, meta)
+        self._data = data
+        return meta, data
+
     @property
     def data(self):
         if self._data is None:
-            meta, data = self.backend.retrieve(self.revid) # raises KeyError if rev does not exist
-            self.meta = Meta(self, self._doc, meta)
-            self._data = data
+            self._load()
         return self._data
 
     def close(self):
@@ -796,7 +800,7 @@
             return True
 
     def __iter__(self):
-        self._meta, self.revision._data = self.revision.backend.retrieve(self.revision.revid) # raises KeyError if rev does not exist
+        self._meta, _ = self.revision._load()
         return iter(self._meta)
 
     def __getitem__(self, key):
@@ -808,7 +812,7 @@
             return self._doc[key]
         except KeyError:
             pass
-        self._meta, self.revision._data = self.revision.backend.retrieve(self.revision.revid) # raises KeyError if rev does not exist
+        self._meta, _ = self.revision._load()
         return self._meta[key]
 
     def __cmp__(self, other):