[issue36345] Deprecate Tools/scripts/serve.py in favour of python -m http.server -d
New submission from Stéphane Wirtel
Change by Stéphane Wirtel
Change by Stéphane Wirtel
STINNER Victor
Serhiy Storchaka
Julien Palard
Brett Cannon
Stéphane Wirtel
STINNER Victor
with your suggestions, I will move the serve.py in the documentation of wsgiref and change Doc/Makefile.
I suggest to write two separated PRs for each change.
----------
_______________________________________
Python tracker
Change by Stéphane Wirtel
Stéphane Wirtel
STINNER Victor
STINNER Victor
Change by Stéphane Wirtel
Ned Deily
Stéphane Wirtel
Ned Deily
Brett Cannon
Stéphane Wirtel
STINNER Victor
Change by Stéphane Wirtel
Brett Cannon
Stéphane Wirtel
Change by Stéphane Wirtel
Change by Stéphane Wirtel
Berker Peksag
STINNER Victor
Please revert 360e1e4c519cfc139de707bcdd1e6c871eec79ee. It's not a good example to put into the documentation.
I looked at other examples: they are nice but far from a "real application". I like the last example which combines multiple wsgiref features and is written like a real application: parse command line arguments, handle CTRL+c, etc.
It uses different naming convention. It would only confuse users relatively new to the wsgiref module and WSGI protocol.
Would you mind to elaborate? I don't understand what you mean by "naming convention" here, sorry.
FileWrapper was supposed to support __getitem__ and __iter__ protocols for compatibility with older Python versions, but its __getiem__ implementation is buggy and is already deprecated. It has no use case in modern Python code.
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 :-)
It has zero exception handling and will return a cryptic traceback if mimetype cannot detect type of the file.
Which kind of exceptions do you expect? The example checks if the file exists for example.
----------
_______________________________________
Python tracker
Berker Peksag
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
STINNER Victor
Change by Stéphane Wirtel
participants (7)
-
Berker Peksag
-
Brett Cannon
-
Julien Palard
-
Ned Deily
-
Serhiy Storchaka
-
STINNER Victor
-
Stéphane Wirtel