From e1f743fa71cf889cf2020f91bcfa4f491d3d3983 Mon Sep 17 00:00:00 2001
From: Helmut Grohne <helmut@subdivi.de>
Date: Sun, 1 Feb 2009 00:39:12 +0100
Subject: added config parameter (for environ) to scgi.forkpool

---
 wsgitools/scgi/forkpool.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'wsgitools/scgi')

diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py
index 0393bb1..90c836a 100644
--- a/wsgitools/scgi/forkpool.py
+++ b/wsgitools/scgi/forkpool.py
@@ -167,7 +167,7 @@ class SCGIServer:
             self.state = state
 
     def __init__(self, wsgiapp, port, interface="localhost", error=sys.stderr,
-                 minworkers=2, maxworkers=32, maxrequests=1000):
+                 minworkers=2, maxworkers=32, maxrequests=1000, config={}):
         """
         @param wsgiapp: is the WSGI application to be run.
         @type port: int
@@ -184,6 +184,9 @@ class SCGIServer:
         @type maxrequests: int
         @param maxrequests: is the number of requests a worker processes before
                 dying
+        @type config: {}
+        @param config: the environ dictionary is updated using these values for
+                each request.
         """
         assert hasattr(error, "write")
         self.wsgiapp = wsgiapp
@@ -192,6 +195,7 @@ class SCGIServer:
         self.minworkers = minworkers
         self.maxworkers = maxworkers
         self.maxrequests = maxrequests
+        self.config = config
         self.error = error
         self.server = None # becomes a socket
         # maps filedescriptors to WorkerStates
@@ -316,7 +320,7 @@ class SCGIServer:
             con.close()
             return
 
-        environ = {}
+        environ = self.config.copy()
         while data:
             key = data.pop(0)
             value = data.pop(0)
-- 
cgit v1.2.3