[Mpuls-commits] r2680 - wasko/branches/2.0/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu May 6 11:13:15 CEST 2010


Author: torsten
Date: 2010-05-06 11:13:14 +0200 (Thu, 06 May 2010)
New Revision: 2680

Modified:
   wasko/branches/2.0/mpulsweb/lib/helpers.py
Log:
* mpulsweb/lib/helpers.py (get_phasesuccessors): Method now used phase
	model to find successort phaseparts of a given phase


Modified: wasko/branches/2.0/mpulsweb/lib/helpers.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/helpers.py	2010-05-06 07:29:07 UTC (rev 2679)
+++ wasko/branches/2.0/mpulsweb/lib/helpers.py	2010-05-06 09:13:14 UTC (rev 2680)
@@ -50,6 +50,7 @@
 
 from mpulsweb.lib.navigation import get_pagename, render_navigation
 from mpulsweb.lib.helper.filters import shorten, nl_to_br, NA
+from mpulsweb.model.phase import PhaseFactory 
 
 
 PRINTABLE = frozenset(printable)
@@ -274,33 +275,14 @@
 # these functions should be moved away from this place
 
 def get_phasesuccessors(p):
-    #p = int(p)
-    phasesuc = []
-    pairs = g.mpuls_config.get('phases', 'pairs')[0]
-    for phase, symbols in pairs.iteritems():
-        if p in symbols:
-            for pair in phase_successors_path(phase, None, True):
-                phasesuc.extend(pairs.get(pair))
-    return phasesuc
-
-def phase_successors(phase):
-    try:
-        suc = g.mpuls_config.get('phases', 'successors')[0][phase]
-        return suc
-    except KeyError:
-        return []
-
-def phase_successors_path(phase, path=None, include_root=False):
-    '''returns list of phase ids (not phasepairs)'''
-    if not path:
-        path = []
-        if include_root:
-            path.append(phase)
-    for p in phase_successors(phase):
-        path.append(p)
-        phase_successors_path(p, path=path)
-    return path
-
-    return phasesuc
-
+    suc = []
+    phaselist = PhaseFactory().build()
+    for phase in phaselist:
+        if p == phase.id:
+            suc.append(phase.start.id)
+            suc.append(phase.end.id)
+            for ppid in phase.end.suc:
+                pp = phaselist.get_phase(ppid)
+                suc.extend(get_phasesuccessors(pp.phase))
+    return suc
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :



More information about the Mpuls-commits mailing list