Add a public API like twisted.internet.test.connectionmixins.serverFactoryFor
|Reported by:||exarkun||Owned by:||therve|
(github, coverage, patch, buildbot, log)
These two lines are simple but typing them out gets tedious:
factory = ServerFactory() factory.protocol = protocol
It would be nice to have this API provided by Twisted somewhere. Ideally it would just be ServerFactory(protocol), but ServerFactory has no __init__ and giving it one breaks this pattern:
class Foo: def __init__(self): self.stuff = things class Bar(ServerFactory, Foo): pass
(since suddenly Bar.__init__ means ServerFactory.__init__ instead of Foo.__init__).
Perhaps we could add a class method, though. ServerFactory.forProtocol(protocol, *args, **kwargs).
Maybe this belongs on Factory rather than ServerFactory, too.