[Mpuls-commits] r3149 - base/trunk/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jul 7 14:39:45 CEST 2010


Author: torsten
Date: 2010-07-07 14:39:44 +0200 (Wed, 07 Jul 2010)
New Revision: 3149

Modified:
   base/trunk/mpulsweb/model/phase.py
Log:
* mpulsweb/model/phase.py (PhaseList.get_reachable_path,
	PhaseList.get_max_phase_id): New methods to determine the max
	reachable (valid) phase from start on.


Modified: base/trunk/mpulsweb/model/phase.py
===================================================================
--- base/trunk/mpulsweb/model/phase.py	2010-07-07 12:38:21 UTC (rev 3148)
+++ base/trunk/mpulsweb/model/phase.py	2010-07-07 12:39:44 UTC (rev 3149)
@@ -148,6 +148,23 @@
             p.phase = '-1'
             return p
 
+    def get_max_phase_id(self):
+        return max(self.get_reachable_path())
+
+    def get_reachable_path(self, phasepart_id='0', only_reachable=True):
+        '''Returns id of max reachable phase which is valid starting from
+        phasepart_id'''
+
+        path = ['-1'] # default unknown phase
+        if self.get_phase(phasepart_id).is_ok():
+            for pp in self.suc.get(phasepart_id, []):
+                if not self.get_phase(pp).is_ok() and only_reachable: 
+                    continue
+                path.extend(self.get_reachable_path(pp))
+                path.append(pp)
+            path.append(phasepart_id)
+        return path
+
     def get_path(self, phasepart_id, only_reachable=False):
         '''Returns a list of phaseparts id from start to the given phasepart_id'''
         path = []



More information about the Mpuls-commits mailing list