Edgewall Software

Opened 10 years ago

Closed 10 years ago

#586 closed defect (worksforme)

Accessing a list into a dictionary inside another dictonary

Reported by: Tim1000 Owned by: cmlenz
Priority: major Milestone: 0.7
Component: Template processing Version: 0.6
Keywords: Cc:

Description

Hello I've a probleme when I try to access my variable wich looks like this data={'varA':{'id':['id1','id2','id3'],'link':['link1','link2','link3'] ,...}}. I can only diplay the keys and values inline (and i would like to display each value one by one) wathever py:for I wrote in my template it don't asigne any value to the variable create in the loop.

For instance : <em py:for="a, b in varA.iteritems()">${a};${b}</em> Throw back <em>;</em> Even <em py:for="a in varAid?">${a};</em>

Change History (2)

comment:1 Changed 10 years ago by anonymous

  • Component changed from Expression evaluation to Template processing

In fact the code wich is inside tags isn't interpreted at all and the one between brackets is interpreted.

comment:2 Changed 10 years ago by hodgestar

  • Resolution set to worksforme
  • Status changed from new to closed

The following works for me:

>>> from genshi.template import MarkupTemplate
>>> MarkupTemplate("<div xmlns:py='http://genshi.edgewall.org/'>"
                   "<em py:for='a, b in d.iteritems()'>${a};${b}</em>"
                   "</div>"
    ).generate(d={"a": 1, "b": 2}).render()

u'<div><em>a;1</em><em>b;2</em></div>'

I suspect there is something else wrong instead?

Note: See TracTickets for help on using tickets.