Changed the implementation of returning tuples from functions

This commit is contained in:
Armin Ronacher 2012-04-09 15:56:33 +01:00
parent 3249eeb438
commit cf1641e5be
5 changed files with 61 additions and 33 deletions

View file

@ -674,8 +674,11 @@ converting return values into response objects is as follows:
returned from the view.
2. If it's a string, a response object is created with that data and the
default parameters.
3. If a tuple is returned the response object is created by passing the
tuple as arguments to the response object's constructor.
3. If a tuple is returned the items in the tuple can provide extra
information. Such tuples have to be in the form ``(response, status,
headers)`` where at least one item has to be in the tuple. The
`status` value will override the status code and `headers` can be a
list or dictionary of additional header values.
4. If none of that works, Flask will assume the return value is a
valid WSGI application and convert that into a response object.

View file

@ -19,6 +19,21 @@ installation, make sure to pass it the ``-U`` parameter::
$ easy_install -U Flask
Version 0.9
-----------
The behavior of returning tuples from a function was simplified. If you
return a tuple it no longer defines the arguments for the response object
you're creating, it's now always a tuple in the form ``(response, status,
headers)`` where at least one item has to be provided. If you depend on
the old behavior, you can add it easily by subclassing Flask::
class TraditionalFlask(Flask):
def make_response(self, rv):
if isinstance(rv, tuple):
return self.response_class(*rv)
return Flask.make_response(self, rv)
Version 0.8
-----------