[wwwsearch-commits] r29101 - wwwsearch/mechanize/trunk/mechanize

jjlee at codespeak.net jjlee at codespeak.net
Wed Jun 21 22:37:15 CEST 2006


Author: jjlee
Date: Wed Jun 21 22:37:14 2006
New Revision: 29101

Added:
   wwwsearch/mechanize/trunk/mechanize/_debug.py
Modified:
   wwwsearch/mechanize/trunk/mechanize/_urllib2.py
   wwwsearch/mechanize/trunk/mechanize/_urllib2_support.py
Log:
Move debug handlers into new module _debug

Added: wwwsearch/mechanize/trunk/mechanize/_debug.py
==============================================================================
--- (empty file)
+++ wwwsearch/mechanize/trunk/mechanize/_debug.py	Wed Jun 21 22:37:14 2006
@@ -0,0 +1,28 @@
+import logging
+
+from urllib2 import BaseHandler
+from _response import response_seek_wrapper
+
+
+class HTTPResponseDebugProcessor(BaseHandler):
+    handler_order = 900  # before redirections, after everything else
+
+    def http_response(self, request, response):
+        if not hasattr(response, "seek"):
+            response = response_seek_wrapper(response)
+        info = logging.getLogger("mechanize.http_responses").info
+        try:
+            info(response.read())
+        finally:
+            response.seek(0)
+        info("*****************************************************")
+        return response
+
+    https_response = http_response
+
+class HTTPRedirectDebugProcessor(BaseHandler):
+    def http_request(self, request):
+        if hasattr(request, "redirect_dict"):
+            info = logging.getLogger("mechanize.http_redirects").info
+            info("redirecting to %s", request.get_full_url())
+        return request

Modified: wwwsearch/mechanize/trunk/mechanize/_urllib2.py
==============================================================================
--- wwwsearch/mechanize/trunk/mechanize/_urllib2.py	(original)
+++ wwwsearch/mechanize/trunk/mechanize/_urllib2.py	Wed Jun 21 22:37:14 2006
@@ -44,12 +44,13 @@
      HTTPRefererProcessor, \
      HTTPRefreshProcessor, \
      HTTPErrorProcessor, \
-     HTTPResponseDebugProcessor, \
-     HTTPRedirectDebugProcessor, \
      HTTPRobotRulesProcessor
 from _upgrade import \
      HTTPRequestUpgradeProcessor, \
      ResponseUpgradeProcessor
+from _debug import \
+     HTTPResponseDebugProcessor, \
+     HTTPRedirectDebugProcessor
 # crap ATM
 ## from _gzip import \
 ##      HTTPGzipProcessor

Modified: wwwsearch/mechanize/trunk/mechanize/_urllib2_support.py
==============================================================================
--- wwwsearch/mechanize/trunk/mechanize/_urllib2_support.py	(original)
+++ wwwsearch/mechanize/trunk/mechanize/_urllib2_support.py	Wed Jun 21 22:37:14 2006
@@ -407,29 +407,6 @@
     https_request = http_request
     https_response = http_response
 
-class HTTPResponseDebugProcessor(BaseHandler):
-    handler_order = 900  # before redirections, after everything else
-
-    def http_response(self, request, response):
-        if not hasattr(response, "seek"):
-            response = response_seek_wrapper(response)
-        info = logging.getLogger("mechanize.http_responses").info
-        try:
-            info(response.read())
-        finally:
-            response.seek(0)
-        info("*****************************************************")
-        return response
-
-    https_response = http_response
-
-class HTTPRedirectDebugProcessor(BaseHandler):
-    def http_request(self, request):
-        if hasattr(request, "redirect_dict"):
-            info = logging.getLogger("mechanize.http_redirects").info
-            info("redirecting to %s", request.get_full_url())
-        return request
-
 class HTTPRefreshProcessor(BaseHandler):
     """Perform HTTP Refresh redirections.
 


More information about the wwwsearch-commits mailing list