[New-bugs-announce] [issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

Dominic Mayers report at bugs.python.org
Thu Mar 30 08:08:53 EDT 2017


New submission from Dominic Mayers:

I am just curious to know if someone considered the idea of passing a factory instance that returns RequestHandlerClass instances instead of directly passing the class? It may affect existing handlers that read non local variables, but there should be a way to make the factory optional. The purpose is only aesthetic and a better organization of the code. I find it awkward to have to subclass the server every time that we have an handler that needs special objects, a database connection, a socket connection to another party, etc. The server class should have a single purpose: accept a request and pass it to an handler. We should only need to subclass a server when we need to do that in a different way : TCP vs UDP, Unix Vs INET, etc. The usage is simpler and more natural. Instead of subclassing the server, we create a factory for the handler.

----------
components: Library (Lib)
messages: 290840
nosy: dominic108
priority: normal
severity: normal
status: open
title: In SocketServer, why not passing a factory instance for the RequestHandlerClass  instead of the class itself?
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29947>
_______________________________________


More information about the New-bugs-announce mailing list