This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Improve socketserver doc
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.5, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: berker.peksag, docs@python, martin.panter, python-dev, terry.reedy
Priority: normal Keywords: patch

Created on 2012-08-09 19:44 by terry.reedy, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
socketserver-doc.patch martin.panter, 2015-02-01 04:38 review
socketserver-doc.2.patch martin.panter, 2015-02-01 12:21 review
Messages (7)
msg167825 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-08-09 19:44
On Windows, 3.3 socketserver defines 12 classes in 3 categories: servers, server mixins, and handlers. (At least, these are the one listed with dir(socketserver). Only BaseServer is indexed. I think all should be. There are also a couple of text issues.

BaseServer - indexed, doc is 20.19.2. Server Objects

TCPServer - mentioned in diagram and text of 20.19.1
UDPServer - ditto
(I presume *nix version have unixxxx classes also)

ForkingMixIn - text of 20.19.1
ThreadingMixIn - ditto


Text says "Forking and threading versions of each type of server can be created using the ForkingMixIn and ThreadingMixIn mix-in classes. For instance, a threading UDP server class is created as follows:
  class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
The mix-in class must come first, since it overrides a method defined in UDPServer."

"can be" means to me that user must create these. I am guessing that pre-defining them was added later. So text should change to 'have been'. The pre-created combinations should be listed. The last sentence could then say "Thhe mix-in class comes first since it overrides...". 


This is documented in 20.19.2 RequestHandler Objects. But instead of starting with something like

class socketserver.BaseRequestHandler 
This is the superclass of all RequestHandler objects. It defines the interface, given below, but does not implement most of the methods, which is done in subclasses. A new instance of the subclass is created for each request.

analogous to the initial entry in 20.19.1, 20.19.2 starts with

"The request handler class must define a new handle() method, and can override any of the following methods. A new instance is created for each request.

I suggest that this be replaced with a standard class entry like the one above. If done, I resume the "RequestHandler" method prefix should be "BaseRequestHandler".

StreamRequestHandler - these two are described in a paragraph
DatagramRequestHandler - after the handle method entry

In summary:
1. index all classes to point to locations indicated above.
2. state that mixin combinations are pre-defined.
3. give BaseRequestHandler a proper entry.
4. revise above as needed for *nix.
5. optionally adjust as needed for 2.7.
msg167843 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-08-09 22:04
BaseRequestHandler.__init__(self, request) apparently attaches request to the instance as self.request.

The methods are called in this order: setup, handle, finish. 
If they must be confusingly documented in the opposite order, it would be good for the head entry to state the correct order.
msg234159 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-01-17 03:39
The post makes a bit more sense once you realize the dotted numbers refer to old section numbers (which have moved on now):

20.19.2 → “Server Objects” section
20.19.1 → “Server Creation Notes”

Regarding point 2: Instructions for the user to make a threading or forking are still relevant when using a subclass (e.g. HTTPServer) that does not come with a predefined subclass. However documenting which predefined classes exist would be nice too.
msg235142 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-02-01 04:38
Here is an attempt to tidy up the socketserver documentation:

1. Added headings for each concrete class and mixin
2. Listed the predefined mixin subclasses
3. Changed RequestHandler to BaseRequestHandler and added class heading
4. Included headings for UnixStream/DatagramServer

Other fixes:
* Fixed many class and method cross references
* Pulled out Stream/DatagramRequestHandler definitions
* Reordered the request handler setup(), handle(), finish() methods
msg235164 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-02-01 12:21
Main changes in socketserver-doc.2.patch:

* Documented constructor parameters for the server classes
* Indented class methods and attributes underneath class headings
msg260500 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-02-19 03:35
New changeset 8b71cd67f548 by Martin Panter in branch '3.5':
Issue #15608: Improve socketserver module documentation

New changeset fbb8b634fe59 by Martin Panter in branch 'default':
Issue #15608: Merge socketserver doc from 3.5
msg260501 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-02-19 04:01
New changeset 9211b7e60c92 by Martin Panter in branch '2.7':
Issue #15608: Improve socketserver module documentation
Date User Action Args
2022-04-11 14:57:34adminsetgithub: 59813
2016-02-19 04:04:09martin.pantersetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 2.7, Python 3.6, - Python 3.4
2016-02-19 04:01:38python-devsetmessages: + msg260501
2016-02-19 03:35:13python-devsetnosy: + python-dev
messages: + msg260500
2015-02-01 12:21:52martin.pantersetfiles: + socketserver-doc.2.patch

messages: + msg235164
2015-02-01 05:02:24berker.peksagsetnosy: + berker.peksag
stage: patch review
type: enhancement

versions: + Python 3.4, Python 3.5, - Python 3.3
2015-02-01 04:38:22martin.pantersetfiles: + socketserver-doc.patch
keywords: + patch
messages: + msg235142
2015-01-17 03:39:19martin.pantersetnosy: + martin.panter
messages: + msg234159
2012-08-09 22:04:50terry.reedysetmessages: + msg167843
2012-08-09 19:44:26terry.reedycreate