Armin Ronacher

New Versions of Werkzeug and Jinja2

written by Armin Ronacher, on Sunday, November 23, 2008 20:44.

I'm happy to announce new versions of the WSGI utility library Werkzeug and the general purpose templating language Jinja in Version 2.

Over the last few months many improvements went into those libraries.

Werkzeug 0.4

Werkzeug 0.4 (codename Schraubenzieher) got many detail improvements, tons of new unittests and a better WSGI and HTTP compatibility:

  • Client supports an empty data argument now.
  • Fixed a bug in Response.application that made it impossible to use it as method decorator.
  • The session system should work on Google's Appengine now
  • The secure cookie works properly in load balanced environments with different cpu architectures now.
  • CacheControl.no_cache and CacheControl.private behavior changed to reflect the possibilities of the HTTP RFC. Setting these attributes to None or True now sets the value to “the empty value”.
  • Fixed a bug in boolean attribute handling of the html and xhtml builders.
  • Added graceful error handling to the debugger pastebin feature and made it compatible with latest lodgeit.
  • added a more list like interface to Headers (slicing and indexing works now)
  • added remove_entity_headers which removes all entity headers from a list of headers (or a Headers object)
  • the responses now automatically call remove_entity_headers if the status code is 304.
  • fixed a bug with Href query parameter handling. Previously the last item of a call to Href was not handled properly if it was a dict.
  • Headers now support a pop operation to better work with environ properties.

Jinja 2.1

Jinja 2.1 (codename Yasuzō) is a new Jinja2 release with tons of new features. A lot of feedback went into improved and new features:

  • The i18n extension looks up foo.ugettext now followed by foo.gettext if an translations object is installed. This makes dealing with custom translations classes easier.
  • added a sort filter that works like dictsort but for arbitrary sequences.
  • implemented a bytecode cache system that improves startup performance for forking applications. (see documentation for more details)
  • Template contexts are now weakref-able.
  • Inclusions and imports "with context" forward all variables now, not only the initial context.
  • Added a cycle helper called cycler.
  • Added a joining helper called joiner.
  • added a compile_expression method to the environment that allows compiling of Jinja expressions into callable Python objects.

Furthermore many bugs where fixed:

  • Fixed a bug with nested loops and the special loop variable. Before the change an inner loop overwrote the loop variable from the outer one after iteration.
  • Fixed a bug with the i18n extension that caused the explicit pluralization block to look up the wrong variable.
  • Fixed a limitation in the lexer that made {{ foo.0.0 }} impossible.
  • Index based subscribing of variables with a constant value returns an undefined object now instead of raising an index error. This was a bug caused by eager optimizing.
  • Fixed a confusing behavior with conditional extending. loops were partially executed under some conditions even though they were not part of a visible area.

Download the latest releases from the cheeseshop:

A new bugfix release of Jinja 1 will follow in the next days, there are some things that have to be figured out first.

Comments

  1. Link to Werkzeug on Cheeseshop returns 404 error. easy_install script also installs Werkzeug 0.3.1

    —  Nick on Monday, November 24, 2008 9:52 #

  2. Fixed the link. Thanks. Why easy_install is trying to download the wrong file I don't know. I'll try to debug that later that day.

    —  Armin Ronacher on Monday, November 24, 2008 16:07 #

  3. Keep up the awesome work, many thanks from a very happy user.

    —  Martin Czura on Thursday, November 27, 2008 1:50 #

  4. Thanks, Armin. I was waiting for the memcached wrapper's `key_prefix` argument that eventually made it to a release.

    —  Jochen Kupperschmidt on Saturday, November 29, 2008 18:31 #

Leave a Reply