-1

I expected this snippet to work:

<div class="footer">
  <? python import time; year = time.strftime('%Y') ?>
  &copy; Copyright 2008-${year}, Agendaless Consulting.
</div>

It instead fails with:

NameError: year

 - Expression: " python import time; year = time.strftime('%Y') ?>
      &copy; Copyright 2008-${year}, Agendaless Consulting."
 - Filename:   /tmp/foo/foo/foo/foo/templates/mytemplate.pt
 - Location:   (74:8)
 - Source:     ... python import time; year = time.strftime('%Y') ?>
                  ^
 - Arguments:  view: <function my_view at 0x7f48d0bca3b0>
               repeat: {...} (0)
               req: <Request - at 0x7f48d29173d0>
               renderer_name: templates/mytemplate.pt
               project: foo
               request: <Request - at 0x7f48d29173d0>
               renderer_info: <RendererHelper - at 0x7f48d0bd1450>
               context: <DefaultRootFactory None at 0x7f48d2917450>

As background, the idea is to avoid having to update the year every year:

<div class="footer">
  &copy; Copyright 2008-2012, Agendaless Consulting.
</div>
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
tshepang
  • 12,111
  • 21
  • 91
  • 136

1 Answers1

0

There should not be whitespace between the first ? and python. The following works well:

<div class="footer">
  <?python import time; year = time.strftime('%Y') ?>
  &copy; Copyright 2008-${year}, Agendaless Consulting.
</div>

Weird.

tshepang
  • 12,111
  • 21
  • 91
  • 136
  • 1
    Perhaps this should be reported as a bug. I think the syntax that includes a space character is much easier to read. It's a shame if it doesn't parse. – malthe May 16 '13 at 09:52