[Mpuls-commits] r5328 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 14 13:52:10 CEST 2011


Author: ludwig
Date: 2011-09-14 13:52:09 +0200 (Wed, 14 Sep 2011)
New Revision: 5328

Modified:
   base/trunk/mpulsweb/lib/navigation.py
Log:
Issue967: Improvement to the method render_navigation. Use a formedTree to
calculate with name2page the error_pages.


Modified: base/trunk/mpulsweb/lib/navigation.py
===================================================================
--- base/trunk/mpulsweb/lib/navigation.py	2011-09-14 11:07:18 UTC (rev 5327)
+++ base/trunk/mpulsweb/lib/navigation.py	2011-09-14 11:52:09 UTC (rev 5328)
@@ -82,9 +82,9 @@
     error_pages = set()
     for fieldandnr in session.get('uncommited_fields', []):
         error_field = fieldandnr.split(IDENTIFIER_SEPARATOR, 1)[0]
-        error_page = tree.field2page.get(error_field, "")
+        error_page = g.formedTree.name2page.get(error_field, "")
         if error_page:
-            error_pages.add(error_page)
+            error_pages.add(error_page.getName())
         
     return tree.render(tree.root, FileCache(), error_pages)
 
@@ -288,8 +288,6 @@
         self.first = None
         self.openfolders = openfolders or []
         self.root = self.build(root, None)
-        self.field2page = {}
-        self.build_dict(root, "")
 
     def build(self, nc, parent):
         if isinstance(nc, RepeatInstanceNode):
@@ -332,25 +330,12 @@
         ti.key = nc.getIdentifier()
         return ti
 
-    def build_dict(self, nc, page_name):
-        meta = nc.getMeta()
-        if isinstance(meta, PageNode):
-            page_name = meta.getName()
-        elif isinstance(meta, RadioNode):
-            self.field2page[meta.getName()] = page_name
-        elif isinstance(meta, Leaf):
-            self.field2page[meta.getName()] = page_name
-        
-        if isinstance(nc, InstanceNode):
-            for child in nc.getChildren():
-                self.build_dict(child, page_name)
 
 class NavigationTree:
 
     def __init__(self, instance, openfolders=None):
         builder = NavigationTreeBuilder(instance.getRootNode(), openfolders)
         self.root = builder.root
-        self.field2page = builder.field2page
         self.first_page = builder.first
 
     def getAllItems(self):



More information about the Mpuls-commits mailing list