summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hellkamp <marc@gsites.de>2011-05-02 19:45:22 +0200
committerMarcel Hellkamp <marc@gsites.de>2011-05-02 20:12:17 +0200
commita07105dd792a0ea88e2a0aae46d3f1b84c074136 (patch)
tree5e5002c6e638059fe9c22ce55c322fe33f4f6212
parentf37ad5401dbb75b48d3f5796ff1ec6b8140ec6ae (diff)
downloadbottle-a07105dd792a0ea88e2a0aae46d3f1b84c074136.tar.gz
fix: Apply plugins immediately in debug mode. This helps a lot during plugin development.
-rwxr-xr-xbottle.py7
-rwxr-xr-xdocs/tutorial.rst9
2 files changed, 10 insertions, 6 deletions
diff --git a/bottle.py b/bottle.py
index 5547bc0..5638890 100755
--- a/bottle.py
+++ b/bottle.py
@@ -480,6 +480,10 @@ class Bottle(object):
caches. If an ID is given, only that specific route is affected. '''
if id is None: self.ccache.clear()
else: self.ccache.pop(id, None)
+ if DEBUG:
+ for route in self.routes:
+ if route['id'] not in self.ccache:
+ self.ccache[route['id']] = self._build_callback(route)
def close(self):
''' Close the application and all installed plugins. '''
@@ -584,6 +588,7 @@ class Bottle(object):
self.routes.append(cfg)
cfg['id'] = self.routes.index(cfg)
self.router.add(rule, verb, cfg['id'], name=name, static=static)
+ if DEBUG: self.ccache[cfg['id']] = self._build_callback(cfg)
return callback
return decorator(callback) if callback else decorator
@@ -1196,11 +1201,11 @@ class TypeFilterPlugin(object):
self.app = app
def add(self, ftype, func):
- if not self.filter and app: self.app.reset()
if not isinstance(ftype, type):
raise TypeError("Expected type object, got %s" % type(ftype))
self.filter = [(t, f) for (t, f) in self.filter if t != ftype]
self.filter.append((ftype, func))
+ if len(self.filter) == 1 and self.app: self.app.reset()
def apply(self, callback, context):
filter = self.filter
diff --git a/docs/tutorial.rst b/docs/tutorial.rst
index 49ae00a..a828343 100755
--- a/docs/tutorial.rst
+++ b/docs/tutorial.rst
@@ -677,9 +677,6 @@ But there is a snag: The plugin sees the whole sub-application as a single route
-.. _tutorial-debugging:
-
-
Development
================================================================================
@@ -726,6 +723,7 @@ Both :func:`app` and :func:`default_app` are instance of :class:`AppStack` and i
app = default_app.pop()
+.. _tutorial-debugging:
Debug Mode
@@ -743,8 +741,9 @@ In this mode, Bottle is much more verbose and provides helpful debugging informa
Here is an incomplete list of things that change in debug mode:
-* A stacktrace is added to the default error page.
-* Templates are not cached anymore.
+* The default error page shows a traceback.
+* Templates are not cached.
+* Plugins are applied immediately.
Just make sure to not use the debug mode on a production server.