Chapter 17.3.2. Output Filters

Just like the input filters, each of these output filters is contained in the cherrypy.filters.output_filters list, which defines the order of the filters that are run. You can configure any of these built-in filters by turning them on in the configuration app.cfg (which can be found in your project’s config folder).

Here’s a sample of how we turn on the static file filter for the /static directory:

[/static]
static_filter.on = True
static_filter.dir = "%(top_level_dir)s/static"

You can use the Output Filters described in Table 17-4 to compress the response before sending it back to the user, or even create XML-RPC output.

Table 17-4. Output Filters
FilterDescription
ResponseHeadersFilterCreates custom headers. ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.