Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Library for WSGI applications

Project description

Pesto is no longer actively maintained. Please check out its successor project, fresco, instead.

Pesto is a library for Python web applications. Its aim is to make writing WSGI web applications easy and fun. Pesto doesn’t constrain you – how you integrate with databases, what templating system you use or how you prefer to lay out your source files is up to you. Above all, pesto is small, well documented and well tested.

Pesto makes it easy to:

  • Map any URI to any part of your application.
  • Produce unicode aware, standards compliant WSGI applications.
  • Interrogate WSGI request information – form variables and HTTP request headers.
  • Create and manipulate HTTP headers, redirects, cookies etc.
  • Integrate with any other WSGI application or middleware, giving you access to a vast and growing resource.

Development status

Pesto is production ready and used on a wide variety of websites.

To browse or check out the latest development version, visit For documentation, visit


Pesto is available under the terms of the new BSD licence.


Full documentation is included with each release. Documentation for the latest version is available at <>.

Version 25

  • Fixed bug in pesto.utils.MultiDict and added a MultiDict.extend method

Version 24

  • Bugfixes for pesto.utils.MultiDict and pesto.dispatch
  • pesto.utils.with_request_args decorator handles malformed input more gracefully

Version 23

  • Fix for exc_info handling

Version 22

  • Partial Python 2.4 backwards compatibility (thanks to Brian Peiris).
  • Improvements to the handling of close methods on content iterators
  • Other minor bugfixes

Version 21

  • HEAD requests are passed to the GET handler if no explicit HEAD handler is set up.
  • DispatcherApp can now take a prefix argument that is prepended to all match patterns
  • Now uses the repoze.lru LRU cache implementation.

Version 20

  • Fixed RuntimeError when used under mod_wsgi (thanks to Mateusz Korniak)
  • Fixed error parsing information out of user-agent cookie headers (thanks to Mateusz Korniak)

Version 19

  • pesto.wsgiutils.serve_static_file now correctly sets the Last-Modified header (thanks to Samuel Wan)
  • Better compliance with HTTP RFC and WSGI spec on 204 No Content and 304 Not Modified responses
  • Restored Python 2.5 compatibility

Version 18

  • PestoWSGIApplication/to_wsgi may now be used to decorate class methods as well as regular functions
  • Minor bugfixes

Version 17

  • pesto.util.MultiDict now retains insertion order of keys. This is useful for form processing where you want to know the order in which fields are submitted.
  • Fixed bugs relating to path handling functions stripping trailing slashes eg in pesto.wsgiutils.make_absolute_url. Also pesto.dispatch.dispatcher_app no longer strips trailing slashes either, it left to the application to do this if desired.

Version 16

  • Fixed error introduced into session handling, where the session cookie was not resent if an old session disappeared

Version 15

  • Corrected package version number
  • Included fixes for session handling (thanks to Ferry Pierre).

Version 14

  • FileSessionManager now saves files under dedicated _pesto_sessions subdirectory, making it safer to use when initialized on a shared temporary directory.
  • Corrected pesto.wsgiutils.mount_app, which previously passed a reference to an out of date request object to sub apps
  • Altered the url() function acquired by dispatcher_app decorated functions to allow script_name, netloc and URL scheme to be specified, making it possible for multiple Pesto dispatcher_apps mounted at different paths or network locations to generate valid URLs for each other.
  • pesto.wsgiutils.with_request_args now raises error objects that may be more easily separated out from other errors in middleware layers if required.
  • now forces a save even if no changes have been detected (which may happen if you store mutable objects in the session)
  • pesto.wsgiutils.with_request_args now raises exceptions generated when parsing arguments from request data. This behaviour is generally more useful to developers than an error page with no information about what parameter is missing.

Version 13

  • Added HttpOnly option to cookies
  • Session middleware can now have the cookie path and domain overridden

Version 12

  • Added a path_info argument to request.make_uri
  • Improved support for dispatcher_app to dispatch to bound methods
  • Added many missing docstrings and other pylint/cheesecake suggested changes
  • Extended request.make_uri to take any query argument that wsgiutils.make_query will accept
  • make_query now supports taking a list of (name, value) tuples

Version 11

  • Removed dbm and rdbms session managers, these were untested, undocumented and were not recommended for use.
  • Added fix for parse_querystring when qs is empty
  • Fixed error on non-UTF8 encoded request body
  • Added X-Pesto-Exception header to help debugging of webapps
  • Improved dispatch debug logging
  • Fixed issue when using dispatcher predicates and caching
  • Reversed dispatcher function matching precedence: the first matching function wins
  • Remove pesto.wsgiutils.MockWSGI and replace with classes in a new pesto.testing module
  • Added a decorators argument to dispatcher_app.match, allowing handler functions to have decorators which are only applied in the context of web requests
  • Request.cookies is now a MultiDict object with the same API as Request.form, Request.files and Request.query
  • Renamed urldispatcher to dispatcher_app to clarify intent of this class.
  • Made response.Response normalize header case and sort headers on ingress, fixing a few consistency issues.
  • Adjusted response header handling to be standards compliant on 304 responses and ETag headers
  • Use wsgiref.validator in MockWSGI
  • Refactored some parts of and into new and modules.
  • Removed dependency on stdlib (see for reasons).
  • Changed variables named ‘encoding’ to ‘charset’ to make the naming more consistent with HTTP.
  • Removed support for Python 2.3. From now on pesto is actively tested on 2.5 and 2.6, and I will try to support 2.4 if bugs are reported.

Version 10

  • Fixes in documentation and packaging, but no changes to functionality

Version 9

  • Added a predicate argument to dispatcher.match, allowing for extra arbitrary checks before routing a URL.
  • Add basic ETag support
  • Removed http exceptions
  • Added support for wsigorg.routing_args
  • WSGI apps created with pesto now have execution deferred until the first iteration. Therefore the iterator’s .close method can be used to reliably release resources etc.
  • Fix for Response objects not catching close methods on upstream content iterators
  • Added onclose kwarg for Response object. Any functions in onclose will be called on the wsgi close event.
  • Added request.files object to complement request.form and request.query
  • Added MultiDict object to replace FieldStorageWrapper
  • Renamed register_pattern to register_converter for consistency
  • Allowed multiple close functions to be passed to ClosingIterator
  • request.make_uri now uri quotes paths
  • Rewrote urldispatcher to use a much more flexible URL matching syntax
  • Refactored Request initialisation to ensure that multiple calls don’t attempt to reinitialize request parameters
  • added Response.getheaders, Response.getheader and Response.from_wsgi
  • add an ExtensiblePattern to dispatcher and enable it by default
  • Changed dispatcher to be a WSGI callable
  • Added wsgiutils.ClosingIterator and wsgiutils.overlay
  • Pesto response objects are now valid WSGI apps
  • Ensure the same Request instance is returned when called multiple times on the same environ object
  • Added a function for mapping request form parameters to function arguments
  • Updated documentation: now requires sphinx for building docs
  • Renamed WSGIRequest to Request for consistency with Response
  • Changed ‘despatcher’ to ‘dispatcher’ throughout, after it was pointed out that no one spells it this way any more

Version 8

  • Merged pesto.utils with pesto.wsgiutils
  • Refactored builtin static server to allow it to be used to serve ad-hoc single files
  • Added a make_query utility function to wsgiutils
  • Fixed request.make_uri when presented with a relative URI. expanded the docstring and tests.
  • Static server fixes for windows environments

Version 7

  • Reimplemented session saving machinery using the WSGI standard close() mechanism.
  • Request.FieldStorageWrapper now raises a KeyError on non-existant item access

Version 6

  • Added uri_join and fixed request.make_uri path concatenation logic
  • Moved debug param out of despatch class and into despatcher_app, where it can be applied across all despatchers in operation
  • Removed duplicate default charset/encoding setting
  • Added Response.bad_request() classmethod
  • Added Response.buffered method
  • Added Response.add_cookie

Version 5

  • Changed wsgiutils.make_absolute_url to bring into line with PEP 333 and improve handling of relative URIs
  • Added Response.redirect, Response.not_found etc classmethods, replacing previous freestanding functions
  • make_query now allows a separator character to be specified
  • pesto.currentrequest() returns None when no request available
  • Add WSGIRequest.query to model querystring data. Both WSGIRequest.form and .query are now properties and lazily instantiated.

Version 4

  • First publicly released version!

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pesto-25.tar.gz (78.9 kB) Copy SHA256 hash SHA256 Source None Jul 25, 2011

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page