[Checkins] SVN: zc.zeoinputlog/branches/replay/src/zc/zeoinputlog/readonlyreplay.py replace httplib with urllib2

Satchidanand Haridas satchit at zope.com
Mon Aug 8 10:39:56 EDT 2011


Log message for revision 122490:
  replace httplib with urllib2

Changed:
  U   zc.zeoinputlog/branches/replay/src/zc/zeoinputlog/readonlyreplay.py

-=-
Modified: zc.zeoinputlog/branches/replay/src/zc/zeoinputlog/readonlyreplay.py
===================================================================
--- zc.zeoinputlog/branches/replay/src/zc/zeoinputlog/readonlyreplay.py	2011-08-08 06:49:43 UTC (rev 122489)
+++ zc.zeoinputlog/branches/replay/src/zc/zeoinputlog/readonlyreplay.py	2011-08-08 14:39:53 UTC (rev 122490)
@@ -19,7 +19,6 @@
 # from Queue import Queue
 
 import cPickle
-import httplib
 import logging
 import marshal
 import optparse
@@ -30,6 +29,7 @@
 import time
 import traceback
 import transaction
+import urllib2
 import urlparse
 import zc.ngi.adapters
 import zc.ngi.async
@@ -281,32 +281,17 @@
     def __init__(self, url, addr, session, inq, outq):
         if not url[-1] == '/':
             url += '/'
-        url = urlparse.urlparse(url)
-        self.blob_prefix = url.path
-        self.blob_url = url.netloc
-        self.blob_conn = httplib.HTTPConnection(self.blob_url)
+        self.blob_url = url
         self.blob_layout = ZODB.blob.BushyLayout()
         Handler.__init__(self, addr, session, inq, outq)
 
     def call(self, op, args):
         if op == 'sendBlob':
-            conn = self.blob_conn
             path = self.blob_layout.getBlobFilePath(*args)
             self.output('request', op, args)
             try:
-                try:
-                    t = time.time()
-                    conn.request("GET", self.blob_prefix+path,
-                                 headers=dict(Connection='Keep-Alive'))
-                    r = conn.getresponse()
-                except httplib.HTTPException:
-                    t = time.time()
-                    conn = self.blob_conn = httplib.HTTPConnection(
-                        self.blob_url)
-                    conn.request("GET", self.blob_prefix+path,
-                                 headers=dict(Connection='Keep-Alive'))
-                    r = conn.getresponse()
-
+                t = time.time()
+                r = urllib2.urlopen(self.blob_url+path)
                 self.read_blob(r)
                 ret = None
             except Exception, v:



More information about the checkins mailing list