summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMarcel Hellkamp <marc@gsites.de>2011-09-02 17:32:57 +0200
committerMarcel Hellkamp <marc@gsites.de>2011-09-02 17:32:57 +0200
commitdf285fa8c680cf3dacea34f2a3e667b587888802 (patch)
treecc3c468719e96dcc7b662dfa41fc04184fee2ea3 /plugins
parent882668ff342e89d6d91fb4138b8546632946d571 (diff)
downloadbottle-df285fa8c680cf3dacea34f2a3e667b587888802.tar.gz
fix: #202 "Deprecation Warning in console" moved to plugin API 2 for all bundled plugins.
Thanks rwxrwx
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sqlite/bottle_sqlite.py9
-rw-r--r--plugins/werkzeug/bottle_werkzeug.py9
2 files changed, 10 insertions, 8 deletions
diff --git a/plugins/sqlite/bottle_sqlite.py b/plugins/sqlite/bottle_sqlite.py
index d79b592..1c55c23 100644
--- a/plugins/sqlite/bottle_sqlite.py
+++ b/plugins/sqlite/bottle_sqlite.py
@@ -44,6 +44,7 @@ class SQLitePlugin(object):
settings on a per-route basis. '''
name = 'sqlite'
+ api = 2
def __init__(self, dbfile=':memory:', autocommit=True, dictrows=True,
keyword='db'):
@@ -61,9 +62,9 @@ class SQLitePlugin(object):
raise PluginError("Found another sqlite plugin with "\
"conflicting settings (non-unique keyword).")
- def apply(self, callback, context):
+ def apply(self, callback, route):
# Override global configuration with route-specific values.
- conf = context['config'].get('sqlite') or {}
+ conf = route.config.get('sqlite') or {}
dbfile = conf.get('dbfile', self.dbfile)
autocommit = conf.get('autocommit', self.autocommit)
dictrows = conf.get('dictrows', self.dictrows)
@@ -71,7 +72,7 @@ class SQLitePlugin(object):
# Test if the original callback accepts a 'db' keyword.
# Ignore it if it does not need a database handle.
- args = inspect.getargspec(context['callback'])[0]
+ args = inspect.getargspec(route.callback)[0]
if keyword not in args:
return callback
@@ -96,4 +97,4 @@ class SQLitePlugin(object):
# Replace the route callback with the wrapped one.
return wrapper
-Plugin = SQLitePlugin \ No newline at end of file
+Plugin = SQLitePlugin
diff --git a/plugins/werkzeug/bottle_werkzeug.py b/plugins/werkzeug/bottle_werkzeug.py
index f8a3f8d..306eb71 100644
--- a/plugins/werkzeug/bottle_werkzeug.py
+++ b/plugins/werkzeug/bottle_werkzeug.py
@@ -50,13 +50,14 @@ class WerkzeugDebugger(DebuggedApplication):
return DebuggedApplication.__call__(self, environ, start_response)
return self.app(environ, start_response)
-
+
class WerkzeugPlugin(object):
""" This plugin adds support for :class:`werkzeug.Response`, all kinds of
:module:`werkzeug.exceptions` and provides a thread-local instance of
:class:`werkzeug.Request`. It basically turns Bottle into Flask. """
name = 'werkzeug'
+ api = 2
def __init__(self, evalex=False, request_class=werkzeug.Request,
debugger_class=WerkzeugDebugger):
@@ -71,7 +72,7 @@ class WerkzeugPlugin(object):
app.wsgi = self.debugger_class(app.wsgi, evalex=self.evalex)
app.catchall = False
- def apply(self, callback, context):
+ def apply(self, callback, route):
def wrapper(*a, **ka):
environ = bottle.request.environ
bottle.local.werkzueg_request = self.request_class(environ)
@@ -89,10 +90,10 @@ class WerkzeugPlugin(object):
''' Return a local proxy to the current :class:`werkzeug.Request`
instance.'''
return werkzeug.LocalProxy(lambda: bottle.local.werkzueg_request)
-
+
def __getattr__(self, name):
''' Convenient access to werkzeug module contents. '''
return getattr(werkzeug, name)
-Plugin = WerkzeugPlugin \ No newline at end of file
+Plugin = WerkzeugPlugin