From 73f9e704c5dec4e44bffad75016710542930731b Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sun, 1 Feb 2009 00:37:53 +0100 Subject: added config parameter (for environ) to scgi.asynchronous --- wsgitools/scgi/asynchronous.py | 11 ++++++++--- 1 file 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() -- cgit v1.2.3