summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantiago Gala <sgala@apache.org>2010-03-13 14:54:49 +0100
committerMarcel Hellkamp <marc@gsites.de>2010-03-13 20:40:36 +0100
commita99242eb0c5ace037376a15b86a2df37f2092666 (patch)
tree8da5d32a0bfd14a6429162155febf1221ca67a04
parent93ec253b3572a85678f447866c71fd9e4631f633 (diff)
downloadbottle-a99242eb0c5ace037376a15b86a2df37f2092666.tar.gz
Filter before test for empty output
So that "{}" can be returned when using autojson, and results in an empty dict and not in an empty output.
-rwxr-xr-xbottle.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/bottle.py b/bottle.py
index f5ff19b..326c7df 100755
--- a/bottle.py
+++ b/bottle.py
@@ -452,6 +452,11 @@ class Bottle(object):
Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like,
iterable of strings and iterable of unicodes
"""
+ # Filtered types (recursive, because they may return anything)
+ for testtype, filterfunc in self.castfilter:
+ if isinstance(out, testtype):
+ return self._cast(filterfunc(out))
+
# Empty output is done here
if not out:
response.headers['Content-Length'] = 0
@@ -474,11 +479,6 @@ class Bottle(object):
out.apply(response)
return self._cast(out.output)
- # Filtered types (recursive, because they may return anything)
- for testtype, filterfunc in self.castfilter:
- if isinstance(out, testtype):
- return self._cast(filterfunc(out))
-
# Cast Files into iterables
if hasattr(out, 'read') and 'wsgi.file_wrapper' in request.environ:
out = request.environ.get('wsgi.file_wrapper',