When I use the below code, the first item is "treed" like it is
supposed to be.  However, when I try to put in additional branches at
the same "level", the information from the previous loops stays, thus,
when a new branch is looped, it will contain information of all
branches before it.

Here's a truncated version of the dictionary:

##########################################
switch_info = {'Router': {'1': {'av_ports': [], 'serial':
'XXXXXXXXXXX', 'model':
'WS-SVC-FWM-1', 'ports': '6', 'card': 'Firewall Module'}, '9':
{'av_ports': [{'status': 'disabled', 'description': '  ', 'duplex':
'full', 'type': 'No Connector', 'VLAN': '1', 'speed': '10G', 'port':
'Te9/1'}, {'status': 'disabled', 'description': '  ', 'duplex':
'full', 'type': 'No Connector', 'VLAN': '1', 'speed': '10G', 'port':
'Te9/2'}], 'serial': 'XXXXXXXXXXX', 'model': 'WS-X6708-10GE', 'ports':
'8', 'card': 'CEF720 8 port 10GE with DFC'}}, 'Switch': {'1':
{'av_ports': [{'status': 'notconnect', 'description': '  ', 'duplex':
'full', 'type': 'No X2', 'VLAN': '1', 'speed': '10G', 'port':
'Te1/1'}, {'status': 'notconnect', 'description': '  ', 'duplex':
'full', 'type': 'No X2', 'VLAN': '1', 'speed': '10G', 'port':
'Te1/2'}, {'status': 'inactive', 'description': '  ', 'duplex':
'full', 'type': 'No Gbic', 'VLAN': '1', 'speed': '1000', 'port':
'Gi1/3'}, {'status': 'inactive', 'description': '  ', 'duplex':
'full', 'type': 'No Gbic', 'VLAN': '1', 'speed': '1000', 'port':
'Gi1/4'}, {'status': 'inactive', 'description': '  ', 'duplex':
'full', 'type': 'No Gbic', 'VLAN': '1', 'speed': '1000', 'port':
'Gi1/5'}, {'status': 'inactive', 'description': '  ', 'duplex':
'full', 'type': 'No Gbic', 'VLAN': '1', 'speed': '1000', 'port':
'Gi1/6'}], 'serial': 'XXYYYYYYYYY', 'model': 'WS-X4516-10GE', 'ports':
'6', 'card': 'Sup V-10GE 10GE (X2), 1000BaseX (SFP)'}}}
#########################################

and here is the template code:

#########################################

And, again,  the code for the javascript tree can be found here:

http://developer.yahoo.com/yui/treeview/

<head>
<!-- Required CSS -->
        link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/
2.2.2/build/treeview/assets/tree.css">

         <!-- Dependency source files -->
         <script src = "http://yui.yahooapis.com/2.2.2/build/yahoo/yahoo-
min.js" ></script>
         <script src = "http://yui.yahooapis.com/2.2.2/build/event/event-
min.js" ></script>

         <!-- TreeView source file -->
         <script src = "http://yui.yahooapis.com/2.2.2/build/treeview/
treeview-min.js" ></script>

<script type="text/javascript">

var tree;
function treeInit() {
   tree = new YAHOO.widget.TreeView("treeDiv1");
   var root = tree.getRoot();
   {% for switches in switch_info %}
       var tmpNode = new YAHOO.widget.TextNode("{{switches}}", root,
false);

   {% for key, value in switch_info.Router.items %}
       var tmpNode1 = new YAHOO.widget.TextNode(" {{value.card}}",
tmpNode, false);

   {% for item in value.av_ports %}
       var tmpNode2 = new YAHOO.widget.TextNode("{{item.port}}
{{item.duplex}}", tmpNode1, false);
   {% endfor %}
   {% endfor %}
   {% endfor %}

   {% for key2, value2 in switch_info.Switch.items %}
       var tmpNode1 = new YAHOO.widget.TextNode("{{value2.card}}",
tmpNode, false);

   {% for item in value2.av_ports %}
       var tmpNode2 = new YAHOO.widget.TextNode("{{item.port}}
{{item.duplex}}", tmpNode1, false);
   {% endfor %}
   {% endfor %}

   tree.draw();
YAHOO.util.Event.addListener(window, "load", treeInit);
}
</script>
</head>

<body onload="treeInit()">

{% block content %}
<div id="treeDiv1"></div>
</body>
########################################


I had to modify it so that the first loop was isolated from the other
loops, but I'm still not sure why these loops do not do the same thing
as the code in the original post.

Anyway, is it possible to make a clean slate for every "branch", or is
there a hiccup in the for loops that can be fixed?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to