mirror of
https://github.com/evennia/evennia.git
synced 2026-04-01 13:37:17 +02:00
PEP8 cleanup of the entire codebase. Unchanged are many cases of too-long lines, partly because of the rewrite they would require but also because splitting many lines up would make the code harder to read. Also the third-party libraries (idmapper, prettytable etc) were not cleaned.
This commit is contained in:
parent
30b7d2a405
commit
1ae17bcbe4
154 changed files with 5613 additions and 4054 deletions
|
|
@ -15,7 +15,7 @@ import urlparse
|
|||
from urllib import quote as urlquote
|
||||
from twisted.web import resource, http
|
||||
from twisted.internet import reactor
|
||||
from twisted.application import service, internet
|
||||
from twisted.application import internet
|
||||
from twisted.web.proxy import ReverseProxyResource
|
||||
from twisted.web.server import NOT_DONE_YET
|
||||
|
||||
|
|
@ -24,6 +24,7 @@ from django.core.handlers.wsgi import WSGIHandler
|
|||
|
||||
from settings import UPSTREAM_IPS
|
||||
|
||||
|
||||
#
|
||||
# X-Forwarded-For Handler
|
||||
#
|
||||
|
|
@ -40,13 +41,14 @@ class HTTPChannelWithXForwardedFor(http.HTTPChannel):
|
|||
proxy_chain = req.getHeader('X-FORWARDED-FOR')
|
||||
if proxy_chain and client_ip in UPSTREAM_IPS:
|
||||
forwarded = proxy_chain.split(', ', 1)[CLIENT]
|
||||
self.transport.client = (forwarded, port)
|
||||
self.transport.client = (forwarded, port)
|
||||
|
||||
|
||||
# Monkey-patch Twisted to handle X-Forwarded-For.
|
||||
|
||||
http.HTTPFactory.protocol = HTTPChannelWithXForwardedFor
|
||||
|
||||
|
||||
class EvenniaReverseProxyResource(ReverseProxyResource):
|
||||
def getChild(self, path, request):
|
||||
"""
|
||||
|
|
@ -58,7 +60,6 @@ class EvenniaReverseProxyResource(ReverseProxyResource):
|
|||
self.host, self.port, self.path + '/' + urlquote(path, safe=""),
|
||||
self.reactor)
|
||||
|
||||
|
||||
def render(self, request):
|
||||
"""
|
||||
Render a request by forwarding it to the proxied server.
|
||||
|
|
@ -77,6 +78,7 @@ class EvenniaReverseProxyResource(ReverseProxyResource):
|
|||
self.reactor.connectTCP(self.host, self.port, clientFactory)
|
||||
return NOT_DONE_YET
|
||||
|
||||
|
||||
#
|
||||
# Website server resource
|
||||
#
|
||||
|
|
@ -92,7 +94,7 @@ class DjangoWebRoot(resource.Resource):
|
|||
Setup the django+twisted resource
|
||||
"""
|
||||
resource.Resource.__init__(self)
|
||||
self.wsgi_resource = WSGIResource(reactor, pool , WSGIHandler())
|
||||
self.wsgi_resource = WSGIResource(reactor, pool, WSGIHandler())
|
||||
|
||||
def getChild(self, path, request):
|
||||
"""
|
||||
|
|
@ -102,6 +104,8 @@ class DjangoWebRoot(resource.Resource):
|
|||
path0 = request.prepath.pop(0)
|
||||
request.postpath.insert(0, path0)
|
||||
return self.wsgi_resource
|
||||
|
||||
|
||||
#
|
||||
# Threaded Webserver
|
||||
#
|
||||
|
|
@ -114,14 +118,16 @@ class WSGIWebServer(internet.TCPServer):
|
|||
|
||||
call with WSGIWebServer(threadpool, port, wsgi_resource)
|
||||
"""
|
||||
def __init__(self, pool, *args, **kwargs ):
|
||||
def __init__(self, pool, *args, **kwargs):
|
||||
"This just stores the threadpool"
|
||||
self.pool = pool
|
||||
internet.TCPServer.__init__(self, *args, **kwargs)
|
||||
|
||||
def startService(self):
|
||||
"Start the pool after the service"
|
||||
internet.TCPServer.startService(self)
|
||||
self.pool.start()
|
||||
|
||||
def stopService(self):
|
||||
"Safely stop the pool after service stop."
|
||||
internet.TCPServer.stopService(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue