diff options
author | Helmut Grohne <helmut@subdivi.de> | 2009-02-01 00:37:53 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2009-02-01 00:37:53 +0100 |
commit | 73f9e704c5dec4e44bffad75016710542930731b (patch) | |
tree | f0695b2a1c84573930052f21b852b2fdd4678f47 | |
parent | 4c332f0d56fd21e6e485410a852bfa4862606fa3 (diff) | |
download | wsgitools-73f9e704c5dec4e44bffad75016710542930731b.tar.gz |
added config parameter (for environ) to scgi.asynchronous
-rw-r--r-- | wsgitools/scgi/asynchronous.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py index 81ed567..7ef10b9 100644 --- a/wsgitools/scgi/asynchronous.py +++ b/wsgitools/scgi/asynchronous.py @@ -16,7 +16,7 @@ class SCGIConnection(asyncore.dispatcher): BODY = 2*4 | 1 # the request header was received, waiting for the body REQ = 3*4 | 2 # request received, sending response def __init__(self, server, connection, addr, maxrequestsize=65536, - maxpostsize=8<<20, blocksize=4096): + maxpostsize=8<<20, blocksize=4096, config={}): asyncore.dispatcher.__init__(self, connection) self.server = server # WSGISCGIServer instance @@ -25,7 +25,7 @@ class SCGIConnection(asyncore.dispatcher): self.maxpostsize = maxpostsize self.blocksize = blocksize self.state = SCGIConnection.NEW # internal state - self.environ = {} # environment passed to wsgi app + self.environ = config.copy() # environment passed to wsgi app self.reqlen = -1 # request length used in two different meanings self.inbuff = "" # input buffer self.outbuff = "" # output buffer @@ -181,7 +181,8 @@ class SCGIServer(asyncore.dispatcher): """SCGI Server for WSGI applications. It does not use multiple processes or multiple threads.""" def __init__(self, wsgiapp, port, interface="localhost", error=sys.stderr, - maxrequestsize=None, maxpostsize=None, blocksize=None): + maxrequestsize=None, maxpostsize=None, blocksize=None, + config={}): """ @param wsgiapp: is the wsgi application to be run. @type port: int @@ -202,6 +203,9 @@ class SCGIServer(asyncore.dispatcher): @type blocksize: int @param blocksize: is amount of data to read or write from or to the network at once + @type config: {} + @param config: the environ dictionary is updated using these values for + each request. """ asyncore.dispatcher.__init__(self) @@ -214,6 +218,7 @@ class SCGIServer(asyncore.dispatcher): self.conf["maxpostsize"] = maxpostsize if blocksize is not None: self.conf["blocksize"] = blocksize + self.conf["config"] = config self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.set_reuse_addr() |