changeset 352:2e7885dc6669

Add lazy loading of Project Entries Only load the Entries of a Project when they are required. This will allow to load also only specific entries from a project.
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 03 Mar 2014 14:26:14 +0100
parents b5dc92631561
children 5ded6192b85b
files getan/project.py
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/getan/project.py	Mon Mar 03 14:24:44 2014 +0100
+++ b/getan/project.py	Mon Mar 03 14:26:14 2014 +0100
@@ -15,11 +15,12 @@
 
 class Project(object):
 
-    def __init__(self, id, key, desc, total):
+    def __init__(self, backend, id, key, desc, total):
+        self.backend = backend
         self.id = id
         self.key = key
         self.desc = desc
-        self.entries = []
+        self._entries = None
         self.total = total
         self.start = None
         self.stop = None
@@ -62,6 +63,15 @@
                 total += (entry.end - start).seconds
         return total
 
+    def load_entries(self, year=None, week=None):
+        self._entries = self.backend.load_entries(self.id, year, week)
+
+    @property
+    def entries(self):
+        if self._entries is None:
+            self.load_entries()
+        return self._entries
+
 
 class Entry(object):
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)