[Mpuls-commits] r2096 - in wasko/branches/2.0: . mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Mar 23 19:26:21 CET 2010


Author: bh
Date: 2010-03-23 19:26:20 +0100 (Tue, 23 Mar 2010)
New Revision: 2096

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCase.__init__): Do not load
phaseslist here.  Loading the phases list is quite expensive and
not needed in most cases.
(MpulsCase.get_phaseslist): New. Load phaseslist on demand.
(MpulsCase.check_consistence, MpulsCase.check_anonymizeability)
(MpulsCase.make_consistent): Use get_phaseslist instead of using
phaseslist directly.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-03-23 15:23:10 UTC (rev 2095)
+++ wasko/branches/2.0/ChangeLog	2010-03-23 18:26:20 UTC (rev 2096)
@@ -1,3 +1,13 @@
+2010-03-23  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/model/case.py (MpulsCase.__init__): Do not load
+	phaseslist here.  Loading the phases list is quite expensive and
+	not needed in most cases.
+	(MpulsCase.get_phaseslist): New. Load phaseslist on demand.
+	(MpulsCase.check_consistence, MpulsCase.check_anonymizeability)
+	(MpulsCase.make_consistent): Use get_phaseslist instead of using
+	phaseslist directly.
+
 2010-03-23  Torsten Irländer <torsten.irlaender at intevation.de>
 
 	Enable default html-escaping for mako-rendering.

Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-03-23 15:23:10 UTC (rev 2095)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-03-23 18:26:20 UTC (rev 2096)
@@ -423,7 +423,7 @@
             preset = dict()
         self.preset = preset
         self.formed_instance = None
-        self.phaseslist = PhaseFactory().load(self.id)
+        self.phaseslist = None
 
     @classmethod
     def set_fields(cls, raw_fields):
@@ -540,6 +540,11 @@
         self._load_formed_instance_tree()
         return self.get_value(name, **kw)
 
+    def get_phaseslist(self):
+        if self.phaseslist is None:
+            self.phaseslist = PhaseFactory().load(self.id)
+        return self.phaseslist
+
     def check_consistence(self, fields=None):
         """Raises ConsistenceCheckException if the case is not completly
         consistent up to the current phase. A case is consistent if no required
@@ -548,13 +553,13 @@
         fields: List of fieldnames which will be checked. On default all fields
                 will be checked
         """
-        self.phaseslist.check_consistence(fields)
+        self.get_phaseslist().check_consistence(fields)
 
     def check_anonymizeability(self, fields=None):
         """Raises ConsistenceCheckException if the case is not in a anonymizable state.  
         """
         # Check if anonymization is allowed in the current phase 
-        phasepart = self.phaseslist.get_current_phase()
+        phasepart = self.get_phaseslist().get_current_phase()
         desc  = g.mpuls_config.get('phases', 'description')[0].get(phasepart.phase)
         if not phasepart.is_anonymizable():
             raise ConsistenceCheckException(
@@ -574,9 +579,10 @@
         to 'unknown'.  Missing relevant datefields (start, end) are set to the
         current date. 
         """
-        curphase = self.phaseslist.get_current_phase_id()
+        phaseslist = self.get_phaseslist()
+        curphase = phaseslist.get_current_phase_id()
         data = {}
-        for phase in self.phaseslist:
+        for phase in phaseslist:
             start, end = phase.getStart(), phase.getEnd()
             if start.id > curphase: break;
             for field in start.fields:



More information about the Mpuls-commits mailing list