Edgewall Software

Opened 18 years ago

Closed 18 years ago

#46 closed defect (fixed)

<py:with> directive doesn't handle multiple assignement

Reported by: cboos Owned by: cmlenz
Priority: minor Milestone: 0.3
Component: Template processing Version: devel
Keywords: py:with Cc:

Description

While trying to find a better workaround for #45, I got another backtrace (not my day :( ):

<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:py="http://markup.edgewall.org/" >

  <body py:match="body">${select('*')}</body>

  <body>

    <!--! This doesn't work, see #45
    <py:for each="idx, (k, v) in enumerate(dict(a=1, b=2).items())">
      <p>$idx: key=$k value=$v</p>
    </py:for>
    -->

    <!--! ... but this workaround doesn't work either -->
    <py:for each="idx, item in enumerate(dict(a=1, b=2).items())"
      py:with="k, v = item">
      <p>$idx: key=$k value=$v</p>
    </py:for>

  </body>
</html>

Fails with:

Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "c:\workspace\src\trac\markup\trunk\markup\template.py", line 1154, in load
    tmpl = Template(fileobj, basedir=dirname, filename=filename)
  File "c:\workspace\src\trac\markup\trunk\markup\template.py", line 755, in __init__
    self.parse()
  File "c:\workspace\src\trac\markup\trunk\markup\template.py", line 810, in parse
    directives.append(cls(value, *pos))
  File "c:\workspace\src\trac\markup\trunk\markup\template.py", line 693, in __init__
    self.vars.append(([n.name for n in node.nodes],
AttributeError: AssTuple instance has no attribute 'name'

Same remark as before, it's not absolutely necessary to support, but if not:

  • it should be documented
  • it should fail more gracefully

... and of course, it would be nice to have it!

Change History (2)

comment:1 Changed 18 years ago by cmlenz

  • Milestone set to 0.3

Yeah, would be nice if that worked as expected.

comment:2 Changed 18 years ago by cmlenz

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

Should be fixed in [276].

Note: See TracTickets for help on using tickets.