What’s New in WebHelpers¶
This is a high-level overview of recent changes. Incompatible changes are in boldface; these may require modifying your application. See Changelog for the full changelog.
webhelpers.paginate: Add URL generator classes for new frameworks like Pyramid.
webhelpers.html.grid: Add ability to use URL generator classes for paged display.
webhelpers.pylonslib.grid: Deprecated. Use webhelpers.html.grid, which now supports paged display.
webhelpers.html: The HTML builder now uses Armin Ronacher’s
“MarkupSafe” package, which Mako and Pylons have also switched to. MarkupSafe
has a C speedup for escaping, escapes single-quotes for greater security (to
close a potential XSS attack route), and adds new methods to
literal is now a subclass of
escape is a wrapper for
text() helper has a “type” argument for new
HTML 5 input types.
webhelpers.html.tags: No longer adds an “id” attribute to hidden fields
generated by the ``form()`` helper, to prevent IDs from clashing if the page
contains multiple forms. To create a hidden field with an ID, call
update_params now supports query parameters with
WebHelpers 1.0 has a lot of new features compared to 0.6.4. Several modules deprecated in 0.6.4 were removed, but otherwise there are only a few API incompatibilities with the 0.6 series.
The following deprecated packages were removed: rails, commands, hinclude,
htmlgen, pagination, and string24. Most of the functionality of the rails
helpers was replaced by new helpers in the
text packages. Prototype and Scriptaculous are not
was replaced by
number_to_human_size() is in the unfinished
directory in the source distribution; you can copy it to your application if
you need it. If you can’t switch to the replacement helpers,
stick with WebHelpers 0.6.4.
webhelpers.html.secure_form was moved to webhelpers.pylonslib.secure_form because it depends on Pylons.
uk_counties() now returns tuples rather than strings.
webhelpers.feedgenerator was upgraded to the Django original (December 2009
version), and the “Geo” classes were added for geographical (GIS) feeds.
Points are latitude/longitude by default, but there’s a flag if your data is
longitude first (as Django is). A
Geometry class was reverse engineered for
other geometries, but it’s untested. Add a “published” property for Atom
New method for producing CDATA sections. The basic tag builders have a
flag to add a newline between content elements and after the tag for
markdown() adds an argument to choose a Markdown implementation.
The Markdown included in WebHelpers will remain at version 1.7, but Markdown
2.x is available on PyPI, and a separate implementation confusingly called
“Markdown2” is also available on PyPI.
New helpers to render HTML to text, and to sanitize user input by stripping HTML tags.
js_obfuscate() from the old rails helpers.
highlight() adds new arguments for flexibility, and
is reimplemented using the HTML builder. The ‘highlighter’ argument is
New helpers to flatten nested lists and tuples, and to
gather all the subclasses of a specified class. There’s an exception
DeclarativeException class for making your own
exceptions with constant messages, and a
format_data_size() and its derivatives
format_bit_size() provide a convenient way to display numbers using SI
units (“1.2 kilobytes”, “1.2 kB”, “1.0 KiB”).
webhelpers.paginate has a new algorithm for generating URLs for page links,
and higher, and has a presliced list option.
On Pylons it will use
pylons.url.current as the URL generator, or fall back
routes.url_for if that is not available. You can also pass a callback
function to the constructor to implement a custom generator. If none of these
are available, you’ll get a
NotImplementedError. Previous versions of
WebHelpers (through 1.0b5) used
routes.url_for unconditionally, but that
function is deprecated and is not supported in Pylons 1.x.
webhelpers.pylonslib is now a package. The
Flash class accepts severity
categories, which you can use to style more severe messages differently. The
session structure is different, so delete existing HTTP sessions when
webhelpers.text adds a suite of helpers from Ruby’s stringex package to
convert strings to URL-friendly format, and to remove inconvenient accents from
New helper to update the query parameters in a URL.
webhelpers.pylonslib.grid contain helpers to
make an HTML table from a list of objects such as database records. It has
a demo program and an optional stylesheet. It’s “experimental” because the
docs aren’t very clear and the API could maybe do with some changes. But it works.
webhelpers.pylonslib.minify contains versions of
stylesheet_link() that compress their files. It’s experimental because
their tests fail, so they probably don’t work.
Other experiments are in the “unfinished” directory in the source distribution.