I'm new to Pyramid and trying to get it to work with me, I've
installed pyramid-1.2.1 in a virtualenv and I'm trying to loop through
a simple list within a template but it seems to me that the statement
"% for item in cisList" does not initialize the "item" variable but if
I call ${cisList[0]['name']} it prints out the name value of cisList.
I cannot see that I'm doing anything different from what is described
in http://docs.pylonsproject.org/docs/pyramid_quick_tutorial.html#list-mako
sample of my code is listed here below and the error it produces
views.py:
...
cisList = [{'name':'test1'},{'name':'test2'}]
#print ex.CIsMap
return {'cisList':cisList}
template.pt:
...
<ul>
% if cisList:
% for item in cisList:
<li>
${item['name']}
</li>
%endfor
% endif
</ul>
...
chameleon.utils.NameError
NameError: item
- Expression: "item['name']"
- Filename: /home/davidoj/workspace/cmdbweb/src/cmdbweb/cmdbweb/
templates/listOfHosts.pt
- Location: (12:10)
- Source: ${item['name']}
^^^^^^^^^^^^
- Expression: "
${item['name']}
"
- Filename: /home/davidoj/workspace/cmdbweb/src/cmdbweb/cmdbweb/
templates/listOfHosts.pt
- Location: (11:8)
- Source: <li>
^
- Arguments: cisList: <list - at 0xba0f78c>
repeat: {...} (0)
renderer_name: cmdbweb:templates/listOfHosts.pt
request: <Request - at 0xbd828ec>
renderer_info: <RendererHelper - at 0x9e8080c>
context: <Root - at 0xbd826ec>
view: <function listHostsView at 0x9e3564c>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.