Skip to content

bottlepy/bottle-werkzeug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bottle-Werkzeug

Werkzeug is a powerfull WSGI utility library for Python. It includes an interactive debugger and feature-packed request and response objects.

This plugin integrates :class:`werkzeug.wrappers.Request` and :class:`werkzeug.wrappers.Response` as an alternative to the built-in implementations, adds support for :mod:`werkzeug.exceptions` and replaces the default error page with an interactive debugger.

Installation

Install with one of the following commands:

$ pip install bottle-werkzeug
$ easy_install bottle-werkzeug

or download the latest version from github:

$ git clone git://github.com/bottlepy/bottle-werkzeug.git
$ cd bottle-werkzeug
$ python setup.py install

Usage

Once installed to an application, this plugin adds support for :class:`werkzeug.wrappers.Response`, all kinds of :mod:`werkzeug.exceptions` and provides a thread-local instance of :class:`werkzeug.wrappers.Request` that is updated with each request. The plugin instance itself doubles as a werkzeug module object, so you don't have to import werkzeug in your application. Here is an example:

import bottle
from bottle.ext import werkzeug

app = bottle.Bottle()
werkzeug = werkzeug.Plugin()
app.install(werkzeug)

req = werkzeug.request # For the lazy.

@app.route('/hello/:name')
def say_hello(name):
    greet = {'en':'Hello', 'de':'Hallo', 'fr':'Bonjour'}
    language = req.accept_languages.best_match(greet.keys())
    if language:
        return werkzeug.Response('%s %s!' % (greet[language], name))
    else:
        raise werkzeug.exceptions.NotAcceptable()

Using the Debugger

This plugin replaces the default error page with an advanced debugger. If you have the evalex feature enabled, you will get an interactive console that allows you to inspect the error context in the browser. Please read Debugging Applications with werkzeug before you enable this feature.

Configuration

The following configuration options exist for the plugin class:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages