[Zope-CVS] CVS: Packages/HTTPMounter - CHANGES.txt:1.1 HTTPMounter.py:1.7

Andreas Jung andreas@digicool.com
Thu, 23 May 2002 13:07:19 -0400


Update of /cvs-repository/Packages/HTTPMounter
In directory cvs.zope.org:/tmp/cvs-serv14764

Modified Files:
	HTTPMounter.py 
Added Files:
	CHANGES.txt 
Log Message:
added retry support in case of a connection failure


=== Added File Packages/HTTPMounter/CHANGES.txt ===
Version 0.12 - (unreleased)

 - added retry-support in case of a failure

Version 0.11 - 05/17/2002

 - minor fixes
 - compatible with Zope 2.3.X
 - added 'View' tab


Version 0.10 - 05/16/2002

 - initial release


=== Packages/HTTPMounter/HTTPMounter.py 1.6 => 1.7 ===
 from OFS.SimpleItem import SimpleItem
 from Acquisition import Implicit
-import string
-import urllib
+import string, time, urllib
 
+MAX_TRIES = 5        # max. number of retries
+TIME2SLEEP = 0.5     # time to sleep in seconds between retries
 
 class HTTPMounter(Persistent, Implicit, SimpleItem):
     """ The HTTPMounter product acts like a dump LocalFS and mounts
@@ -65,8 +66,18 @@
         url = self.url 
         if url[-1] != '/': url = url + '/'
         url = url + sub_path
-        data = urllib.urlopen(url).read()
-        return data
+
+        tries = 0
+
+        while tries<MAX_TRIES:
+            try:        
+                data = urllib.urlopen(url).read()
+                return data
+            except IOError:
+                tries = tries + 1
+                time.sleep(TIME2SLEEP)
+
+        return IOError
 
 
     def manage_preferences(self, title, url, default_document, RESPONSE=None, URL1=None):
@@ -95,4 +106,3 @@
     if REQUEST is not None:
         return self.manage_main(self, REQUEST,update_menu=1)
     
-