On Dec 13, 9:07 pm, "Jeff Hinrichs - DM&T" <[EMAIL PROTECTED]> wrote:
> I am trying to use a list of dicts in my templates and I can't figure
> out how to access the values. Here is what I am trying:
>
> from the controller ...
> ------------------------------------------
> tList = [
> {'foo':1,'bar':2},
> {'foo':3,'bar':4}
> ]
>
> return tList
> -----------------------------------------
> my kid template snippet:
> -----------------------------------------
> <li py:for="t in tList">
> <span py:replace="t.foo">foo</span> --
> <span py:replace="t.bar">bar </span>
> <hr width="300" align="left"/>
> </li>
> ------------------------------------------
>
> When I try it, cherrypy complains:
> TypeError: sequence item 0: expected string, dict found
>
> So I tried:
> my kid template snippet:
> -----------------------------------------
> <li py:for="t in tList">
> <span py:replace="t['foo']">foo</span> --
> <span py:replace="t['bar']">bar </span>
> <hr width="300" align="left"/>
> </li>
> ------------------------------------------
Ok -- so now, this is working
-----------------------------------------
<li py:for="t in tList">
<span py:replace="t['foo']">foo</span> --
<span py:replace="t['bar']">bar </span>
<hr width="300" align="left"/>
</li>
------------------------------------------
hmmm... don't know why it didn't at first -- me, I'm sure.
> and cherrypy says:
> TypeError: sequence item 0: expected string, dict found
>
> As you can tell, this is the first non-simple construct I've passed
> back from a controller and I am befuddled. If someone could point me
> in the right direction I'd appreciate it.
>
> thanks,
> Jeff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---