Edgewall Software

Opened 12 years ago

Closed 12 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:


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"

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

  <body py:match="body">${select('*')}</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>

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


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__
  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 (0)

Change History (2)

comment:1 Changed 12 years ago by cmlenz

  • Milestone set to 0.3

Yeah, would be nice if that worked as expected.

comment:2 Changed 12 years ago by cmlenz

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

Should be fixed in [276].

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain cmlenz.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.