title: Name error while using chameleon templating in Pyramid framework
body: <p>I found this error while trying to run javascript in chameleon template, with pyramid framework. </p>
  
  <p>This is the code that fetches data from the sqlite database.</p>
  
  <pre><code>@view_config(route_name='ddo2', renderer='../templates/pages/testpage.pt')
  def ddo2(request):
      query = request.dbsession.query(UserRoles)
      allusers = query.filter(UserRoles.role_id == 1).all()
      length = len(allusers)
      return {'all_users':allusers,'length':length}
  </code></pre>
  
  <p>The chameleon template file testpage.pt goes like this,</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
  
  function createMany(nums){
  
      var str = "";
  
      for(i=0;i&lt;nums;i++){
  
          str += "&lt;input type='radio' name='value1'  /&gt;${all_users[i].id}  &lt;br&gt;";
  
  }
  
      document.getElementById("divTxt").innerHTML = str;
  
  }
  
  
   &lt;/script&gt;
  
  &lt;p&gt;
  
  
  
    &lt;input type="button" name="button" id="button" value="To view user details click this" onclick="createMany(${length});" /&gt;
  
  
  
  &lt;/p&gt;
  
  &lt;div id="divTxt"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Error page shows up saying Name error:i </p>
  
  <pre><code> NameError: i
  
   - Expression: "${all_users[i].id}  "
   - Filename:   c:\nic\pro\scripts\nic\nic\templates\pages\testpage.pt
   - Location:   (line 11: col 57)
    - Source:     ... adio' name='value1'  /&gt;${all_users[i].id}  &lt;br&gt;";
                                            ^^^^^^^^^^^^^^^^^^^^
   - Arguments:  repeat: {...} (0)
             renderer_name: ../templates/pages/testpage.pt
             req: &lt;Request - at 0x560e940L&gt;
             request: &lt;Request - at 0x560e940L&gt;
             renderer_info: &lt;RendererHelper - at 0x56b53c8L&gt;
             length: 2
             context: &lt;instance None at 0x56a9988L&gt;
             all_users: &lt;list - at 0x56a9e88L&gt;
             view: &lt;function ddo2 at 0x55d54a8L&gt;
  </code></pre>
  
  <p>Thanks for any help. :)</p>