[Inteproxy-commits] r135 - in trunk: . inteproxy test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jun 11 17:08:58 CEST 2008


Author: bh
Date: 2008-06-11 17:08:57 +0200 (Wed, 11 Jun 2008)
New Revision: 135

Modified:
   trunk/ChangeLog
   trunk/inteproxy/main.py
   trunk/inteproxy/proxycore.py
   trunk/test/test_inteproxy.py
Log:
Make the transcoder map an attribute of the server object.
There's no need for a global transcoder map anymore

* inteproxy/transcoder.py (transcoder_map): Removed. There is no
longer a global transcoder map

* inteproxy/proxycore.py (MasterWorkerServer.__init__): New
parameter and instance variable transcoder_map for the request
handlers to find the transcoders
(InteProxyHTTPRequestHandler.handle_proxy_request): Use the
server's transcoder_map instead of the global one

* inteproxy/main.py (run_server): Create a new transcoder map
instead of simply populating the global one and pass the
transcoder map to the MasterWorkerServer

* test/test_inteproxy.py (ServerTest.setUp): Pass a new empty
transcoder map to the MasterWorkerServer


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-06-10 18:20:26 UTC (rev 134)
+++ trunk/ChangeLog	2008-06-11 15:08:57 UTC (rev 135)
@@ -1,3 +1,24 @@
+2008-06-11  Bernhard Herzog  <bh at intevation.de>
+
+	Make the transcoder map an attribute of the server object.
+	There's no need for a global transcoder map anymore
+
+	* inteproxy/transcoder.py (transcoder_map): Removed. There is no
+	longer a global transcoder map
+
+	* inteproxy/proxycore.py (MasterWorkerServer.__init__): New
+	parameter and instance variable transcoder_map for the request
+	handlers to find the transcoders
+	(InteProxyHTTPRequestHandler.handle_proxy_request): Use the
+	server's transcoder_map instead of the global one
+
+	* inteproxy/main.py (run_server): Create a new transcoder map
+	instead of simply populating the global one and pass the
+	transcoder map to the MasterWorkerServer
+
+	* test/test_inteproxy.py (ServerTest.setUp): Pass a new empty
+	transcoder map to the MasterWorkerServer
+
 2008-06-10  Bernhard Herzog  <bh at intevation.de>
 
 	* test/test_inteproxy.py: New.  Functional tests for InteProxy

Modified: trunk/inteproxy/main.py
===================================================================
--- trunk/inteproxy/main.py	2008-06-10 18:20:26 UTC (rev 134)
+++ trunk/inteproxy/main.py	2008-06-11 15:08:57 UTC (rev 135)
@@ -157,7 +157,8 @@
     HandlerClass.allow_shutdown = opts.allow_shutdown
     HandlerClass.debug_level = opts.debug_level
 
-    inteproxy.transcoder.transcoder_map.read_config(opts.config_file)
+    transcoder_map = inteproxy.transcoder.create_transcoder_map()
+    transcoder_map.read_config(opts.config_file)
 
     setup_language()
 
@@ -173,7 +174,7 @@
     sys.stderr.write("[%s] server starting up\n" % log_date_time_string())
 
     httpd = ServerClass(server_address, HandlerClass, opts.workers,
-                        httpopener, http10opener)
+                        httpopener, http10opener, transcoder_map=transcoder_map)
 
     # import the gtkapp here instead of at top-level to avoid loading
     # the gtk module.  The gtk module requires an Xserver connection

Modified: trunk/inteproxy/proxycore.py
===================================================================
--- trunk/inteproxy/proxycore.py	2008-06-10 18:20:26 UTC (rev 134)
+++ trunk/inteproxy/proxycore.py	2008-06-11 15:08:57 UTC (rev 135)
@@ -86,8 +86,8 @@
         #
         # Determine the transcoder to use
         #
-        transcoder_map = inteproxy.transcoder.transcoder_map
-        transcoder = transcoder_map.get_transcoder(self.command, self.path)
+        transcoder = self.server.transcoder_map.get_transcoder(self.command,
+                                                               self.path)
 
         #
         # convert request according to the transcoder rules
@@ -291,10 +291,11 @@
     do_shutdown = False
 
     def __init__(self, server_address, RequestHandlerClass, num_workers,
-                 http11_opener, http10_opener):
+                 http11_opener, http10_opener, transcoder_map):
         HTTPServer.__init__(self, server_address, RequestHandlerClass)
         self.http11_opener = http11_opener
         self.http10_opener = http10_opener
+        self.transcoder_map = transcoder_map
         self.thread_pool = ThreadPool(num_workers, lambda f: f())
         sys.stderr.write("[%s] starting %d worker threads\n" \
                          % (log_date_time_string(), num_workers))
@@ -326,3 +327,4 @@
                          % (log_date_time_string(), client_address))
         traceback.print_exception(*(sys.exc_info() + (None, sys.stderr)))
         sys.stderr.flush()
+

Modified: trunk/test/test_inteproxy.py
===================================================================
--- trunk/test/test_inteproxy.py	2008-06-10 18:20:26 UTC (rev 134)
+++ trunk/test/test_inteproxy.py	2008-06-11 15:08:57 UTC (rev 135)
@@ -15,6 +15,7 @@
 import serversupport
 
 from inteproxy.proxycore import MasterWorkerServer, InteProxyHTTPRequestHandler
+from inteproxy.transcoder import create_transcoder_map
 from inteproxy.main import build_opener
 import inteproxy.httpserver as httpserver
 
@@ -34,7 +35,8 @@
         proxyserver = MasterWorkerServer(("127.0.0.1", 0),
                                          InteProxyHTTPRequestHandler, 5,
                                          build_opener(None, 0),
-                                         build_opener(None, 0, 10))
+                                         build_opener(None, 0, 10),
+                                         transcoder_map=create_transcoder_map())
         self.server = httpserver.ServerThread(proxyserver)
         self.server.start(daemon=True)
         remote_server = serversupport.HTTPServer(self.remote_contents)



More information about the Inteproxy-commits mailing list