Index: src/zc/buildout/download.py
===================================================================
--- src/zc/buildout/download.py	(revisão 119589)
+++ src/zc/buildout/download.py	(cópia de trabalho)
@@ -61,6 +61,7 @@
         self.cache = cache
         if cache == -1:
             self.cache = options.get('download-cache')
+        self.network_cache = options.get('network-cache', None)
         self.namespace = namespace
         self.offline = offline
         if offline == -1:
@@ -139,7 +140,43 @@
             _, is_temp = self.download(url, md5sum, cached_path)
 
         return cached_path, is_temp
+   
+    def download_network_cached(self, path, md5sum):
+        """Download from a network cache provider
 
+        If something fail (providor be offline, or md5sum fail), we ignore
+        network cached files.
+        
+        return True if download succeeded.
+        """
+        url = os.path.join(self.network_cache, md5sum)
+        self.logger.info('Downloading from network cache %s' % url)
+        try:
+            path, headers = urllib.urlretrieve(url, path)
+            if not check_md5sum(path, md5sum):
+                self.logger.info('MD5 checksum mismatch downloading %r' % url)
+                return False
+        except IOError, e:
+            self.logger.info('Fail to download from network cache %s' % url)
+            return False
+
+        return True
+
+    def upload_network_cached(self, path, md5sum):
+        """Upload file to a network cache server"""
+        try:
+            f = open(path, 'r')
+            data = f.read()
+            url = os.path.join(self.network_cache, md5sum)
+            try:
+                result = urllib.urlopen(url, urllib.urlencode({
+                    "data" : data}))
+            except (IOError,EOFError), e:
+                self.logger.info('Fail to upload cache on %s' % url)
+        finally:
+            f.close()
+        return True
+
     def download(self, url, md5sum=None, path=None):
         """Download a file from a URL to a given or temporary path.
 
@@ -173,10 +210,16 @@
         handle, tmp_path = tempfile.mkstemp(prefix='buildout-')
         try:
             try:
-                tmp_path, headers = urllib.urlretrieve(url, tmp_path)
-                if not check_md5sum(tmp_path, md5sum):
-                    raise ChecksumError(
-                        'MD5 checksum mismatch downloading %r' % url)
+                is_downloaded = False
+                if None not in [md5sum , self.network_cache]:
+                    is_downloaded = self.download_network_cached(tmp_path, md5sum)
+
+                if not is_downloaded:
+                    tmp_path, headers = urllib.urlretrieve(url, tmp_path)
+                    if not check_md5sum(tmp_path, md5sum):
+                        raise ChecksumError(
+                            'MD5 checksum mismatch downloading %r' % url)
+                    self.upload_network_cached(tmp_path, md5sum)
             finally:
                 os.close(handle)
         except:
