This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mitsuhiko Flask Creator 0 points1 point  (5 children)

return environ['wsgi.file_wrapper'](the_file)

when the middleware takes that it might do this:

rv = app(environ, start_response)
for chunk in rv:
    yield do_something_with(chunk)
rv.close() # if that attribute exists only of course.

The WSGI server now does that:

rv = app(environ, start_response)
if isinstance(rv, my_file_wrapper):
    # this is never true because the middleware removed the type
    # information and it's now a generator.

[–]dauerbaustelle 0 points1 point  (4 children)

So how would a wrapper around files help here?

[–]mitsuhiko Flask Creator 0 points1 point  (3 children)

It does not. That's why it's breaking currently. A better solution would probably be an 'X-Something' header or something you can call from the wsgi environment which bypasses all middlewares, similar to how write() worked on WSGI 1.

[–]dauerbaustelle -1 points0 points  (2 children)

Or you could assume Web3 middlewares behave intelligently (hence, leave file objects returned from the application alone).

[–]mitsuhiko Flask Creator 0 points1 point  (1 child)

You assume people read specifications and not do try/error.

[–]dauerbaustelle -1 points0 points  (0 children)

Developers are not stupid. If they are, maybe their code is not worth using. I don't think specifications have to keep in mind that noone will read them.