Berker Peksag <berker.pek...@gmail.com> added the comment:

> I looked at other examples: they are nice but far from a "real application".

You can use the same argument for pretty much every example in the stdlib 
documentation :)

wsgiref is a low level module, users should use projects like WebOb instead. 
Also, a complete example would need to contain basic routing and middleware 
support (which is not easy to implement correctly)

> Would you mind to elaborate? I don't understand what you mean by "naming 
> convention" here, sorry.

For example, the response() callable in the example is explicitly documented as 
start_response() in PEP 3333:

    https://www.python.org/dev/peps/pep-3333/#the-start-response-callable

You can read PEP 3333 for more details.

> Do you mean that app() must not return FileWrapper? How do you return file 
> content in that case?
> Maybe FileWrapper API should be clarified? It's surprising to read Python 3.8 
> mentioning compatibility with Python 2.1 :-)

The whole point of the API was to support both __getitem__ and __iter__ 
protocols at the same time without breaking user code. I've already deprecated 
the support for __getitem__ protocol (84a13fbda0d79789e3c9efcc9f64752261ce1e8d) 
because it wasn't working as expected (it ignores its 'index' argument)

Its only valid use case is to read a file chunk by chunk by using its blksize 
argument, but there are much better ways to achieve the same thing (use 
os.sendfile() or nginx :))

> Which kind of exceptions do you expect? The example checks if the file exists 
> for example.

I'm talking about exceptions that can be raised by the application code, such 
as the one that I've mentioned (i.e. mimetypes) in my earlier comment.

Sorry, but it's not really a good example to put into documentation and it 
would be much better if we could save our bikeshedding bandwidth to other 
issues :)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36345>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to