https://github.com/bottlepy/bottle-werkzeug
https://github.com/bottlepy/bottle-werkzeug
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bottlepy/bottle-werkzeug
- Owner: bottlepy
- Created: 2014-03-11T15:57:02.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-05-24T08:43:19.000Z (about 9 years ago)
- Last Synced: 2025-04-10T00:28:29.466Z (about 1 year ago)
- Language: Python
- Size: 9.77 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
=====================
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:
* **evalex**: Enable the exception evaluation feature (interactive debugging). This requires a non-forking server and is a security risk. Please read `Debugging Applications with werkzeug `_. (default: False)
* **request_class**: Defaults to :class:`werkzeug.wrappers.Request`
* **debugger_class**: Defaults to a subclass of :class:`werkzeug.debug.DebuggedApplication` which obeys the :data:`bottle.DEBUG` setting.