diff options
author | Marcel Hellkamp <marc@gsites.de> | 2011-05-02 21:28:35 +0200 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2011-05-02 21:28:35 +0200 |
commit | 287b12a0140d039720933823853e59053b285217 (patch) | |
tree | d0b3907076235e834d46848a47b82ca2e7b9f004 | |
parent | a07105dd792a0ea88e2a0aae46d3f1b84c074136 (diff) | |
download | bottle-287b12a0140d039720933823853e59053b285217.tar.gz |
The bottle_werkzeug setup.py learned some new tricks.
-rw-r--r-- | plugins/werkzeug/bottle_werkzeug.py | 3 | ||||
-rw-r--r-- | plugins/werkzeug/setup.py | 44 |
2 files changed, 12 insertions, 35 deletions
diff --git a/plugins/werkzeug/bottle_werkzeug.py b/plugins/werkzeug/bottle_werkzeug.py index 1e68996..ce97962 100644 --- a/plugins/werkzeug/bottle_werkzeug.py +++ b/plugins/werkzeug/bottle_werkzeug.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ This plugin adds support for :class:`werkzeug.Response`, all kinds of :exc:`werkzeug.HTTPException` and provides a thread-local instance of @@ -34,6 +33,8 @@ __autor__ = "Marcel Hellkamp" __version__ = '0.1' __license__ = 'MIT' +### CUT HERE (see setup.py) + import werkzeug from werkzeug import * import bottle diff --git a/plugins/werkzeug/setup.py b/plugins/werkzeug/setup.py index f689b39..aa733eb 100644 --- a/plugins/werkzeug/setup.py +++ b/plugins/werkzeug/setup.py @@ -1,38 +1,7 @@ #!/usr/bin/env python -""" -This plugin adds support for :class:`werkzeug.Response`, all kinds of -:exc:`werkzeug.HTTPException` and provides a thread-local instance of -:class:`werkzeug.Request`. It basically turns Bottle into Flask. - -The plugin instance doubles as a werkzeug module object, so you don't need to -import werkzeug in your application. - -For werkzeug library documentation, see: http://werkzeug.pocoo.org/ - -Example:: - - import bottle - from bottle.ext.werkzeug import WerkzeugPlugin - - app = bottle.Bottle() - werkzeug = app.install(WerkzeugPlugin()) - wrequest = werkzueg.request # For the lazy. - - @app.route('/hello/:name') - def say_hello(name): - greet = {'en':'Hello', 'de':'Hallo', 'fr':'Bonjour'} - language = wrequest.accept_language.best_match(greet.keys()) - if language: - return werkzeug.Response('%s %s!' % (greet[language], name)) - else: - raise werkzeug.exceptions.NotAcceptable() - -""" - import sys import os -import re from distutils.core import setup try: @@ -40,15 +9,22 @@ try: except ImportError: from distutils.command.build_py import build_py +# This ugly hack executes the first few lines of the module file to look up some +# common variables. We cannot just import the module because it depends on other +# modules that might not be installed yet. +filename = os.path.join(os.path.dirname(__file__), 'bottle_werkzeug.py') +source = open(filename).read().split('### CUT HERE')[0] +exec(source) + setup( name = 'bottle-werkzeug', - version = '0.1', + version = __version__, url = 'http://bottlepy.org/docs/dev/plugin/werkzeug/', - description = 'Werkzeug integration for Bottle', + description = 'Werkzeug integration for Bottle.', long_description = __doc__, author = 'Marcel Hellkamp', author_email = 'marc@gsites.de', - license = 'MIT', + license = __license__, platforms = 'any', py_modules = [ 'bottle_werkzeug' |