Edgewall Software

Ticket #46 (closed defect: fixed)

Opened 8 years ago

Last modified 8 years ago

<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!

Attachments

Change History

Changed 8 years ago by cmlenz

  • milestone set to 0.3

Yeah, would be nice if that worked as expected.

Changed 8 years ago by cmlenz

  • status changed from new to closed
  • resolution set to fixed

Should be fixed in [276].

Add/Change #46 (<py:with> directive doesn't handle multiple assignement)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.