Made top-level server/ directory google-style docstring compliant as per #709.

This commit is contained in:
Griatch 2015-06-23 13:30:59 +02:00
parent 00b5309295
commit 6d0122906f

View file

@ -31,9 +31,14 @@ UPSTREAM_IPS = settings.UPSTREAM_IPS
# #
class HTTPChannelWithXForwardedFor(http.HTTPChannel): class HTTPChannelWithXForwardedFor(http.HTTPChannel):
"""
HTTP xforward class
"""
def allHeadersReceived(self): def allHeadersReceived(self):
""" """
Check to see if this is a reverse proxied connection. Check to see if this is a reverse proxied connection.
""" """
CLIENT = 0 CLIENT = 0
http.HTTPChannel.allHeadersReceived(self) http.HTTPChannel.allHeadersReceived(self)
@ -55,7 +60,15 @@ class EvenniaReverseProxyResource(ReverseProxyResource):
""" """
Create and return a proxy resource with the same proxy configuration Create and return a proxy resource with the same proxy configuration
as this one, except that its path also contains the segment given by as this one, except that its path also contains the segment given by
C{path} at the end. path at the end.
Args:
path (str): Url path.
request (Request object): Incoming request.
Return:
resource (EvenniaReverseProxyResource): A proxy resource.
""" """
return EvenniaReverseProxyResource( return EvenniaReverseProxyResource(
self.host, self.port, self.path + '/' + urlquote(path, safe=""), self.host, self.port, self.path + '/' + urlquote(path, safe=""),
@ -64,6 +77,13 @@ class EvenniaReverseProxyResource(ReverseProxyResource):
def render(self, request): def render(self, request):
""" """
Render a request by forwarding it to the proxied server. Render a request by forwarding it to the proxied server.
Args:
request (Request): Incoming request.
Returns:
not_done (char): Indicator to note request not yet finished.
""" """
# RFC 2616 tells us that we can omit the port if it's the default port, # RFC 2616 tells us that we can omit the port if it's the default port,
# but we have to provide it otherwise # but we have to provide it otherwise
@ -92,15 +112,24 @@ class DjangoWebRoot(resource.Resource):
""" """
def __init__(self, pool): def __init__(self, pool):
""" """
Setup the django+twisted resource Setup the django+twisted resource.
Args:
pool (ThreadPool): The twisted threadpool.
""" """
resource.Resource.__init__(self) resource.Resource.__init__(self)
self.wsgi_resource = WSGIResource(reactor, pool, WSGIHandler()) self.wsgi_resource = WSGIResource(reactor, pool, WSGIHandler())
def getChild(self, path, request): def getChild(self, path, request):
""" """
To make things work we nudge the To make things work we nudge the url tree to make this the
url tree to make this the root. root.
Args:
path (str): Url path.
request (Request object): Incoming request.
""" """
path0 = request.prepath.pop(0) path0 = request.prepath.pop(0)
request.postpath.insert(0, path0) request.postpath.insert(0, path0)
@ -118,18 +147,32 @@ class WSGIWebServer(internet.TCPServer):
so as to register correctly with the twisted daemon. so as to register correctly with the twisted daemon.
call with WSGIWebServer(threadpool, port, wsgi_resource) call with WSGIWebServer(threadpool, port, wsgi_resource)
""" """
def __init__(self, pool, *args, **kwargs): def __init__(self, pool, *args, **kwargs):
"This just stores the threadpool" """
This just stores the threadpool.
Args:
pool (ThreadPool): The twisted threadpool.
args, kwargs (any): Passed on to the TCPServer.
"""
self.pool = pool self.pool = pool
internet.TCPServer.__init__(self, *args, **kwargs) internet.TCPServer.__init__(self, *args, **kwargs)
def startService(self): def startService(self):
"Start the pool after the service" """
Start the pool after the service starts.
"""
internet.TCPServer.startService(self) internet.TCPServer.startService(self)
self.pool.start() self.pool.start()
def stopService(self): def stopService(self):
"Safely stop the pool after service stop." """
Safely stop the pool after the service stops.
"""
internet.TCPServer.stopService(self) internet.TCPServer.stopService(self)
self.pool.stop() self.pool.stop()