diff options
author | Santiago Gala <sgala@apache.org> | 2010-03-13 14:54:49 +0100 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2010-03-13 20:40:36 +0100 |
commit | a99242eb0c5ace037376a15b86a2df37f2092666 (patch) | |
tree | 8da5d32a0bfd14a6429162155febf1221ca67a04 | |
parent | 93ec253b3572a85678f447866c71fd9e4631f633 (diff) | |
download | bottle-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-x | bottle.py | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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', |