[Checkins] SVN: zc.buildout/branches/tlotze-download-api/src/zc/buildout/download. never create cached copies of local resources

Thomas Lotze tl at gocept.com
Mon Jun 8 04:47:47 EDT 2009


Log message for revision 100740:
  never create cached copies of local resources

Changed:
  U   zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py
  U   zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt

-=-
Modified: zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py
===================================================================
--- zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py	2009-06-08 07:46:04 UTC (rev 100739)
+++ zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.py	2009-06-08 08:47:46 UTC (rev 100740)
@@ -83,7 +83,8 @@
         Returns the path to the downloaded file.
 
         """
-        if self.cache is None:
+        if (self.cache is None
+            or urlparse.urlparse(url, 'file').scheme == 'file'):
             return self.download(url, md5sum, path)
 
         cached_path = self.download_cached(url, md5sum)

Modified: zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt
===================================================================
--- zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt	2009-06-08 07:46:04 UTC (rev 100739)
+++ zc.buildout/branches/tlotze-download-api/src/zc/buildout/download.txt	2009-06-08 08:47:46 UTC (rev 100740)
@@ -200,10 +200,24 @@
 >>> cat(download(server_url+'foo.txt'))
 This is a foo text.
 
->>> remove(path)
+On the other hand, local resources will never be cached:
+
 >>> remove(cache, 'foo.txt')
+>>> ls(cache)
+
 >>> write(server_data, 'foo.txt', 'This is a foo text.')
+>>> download = Download({'download-cache': cache})
 
+>>> cat(download('file://' + join(server_data, 'foo.txt'), path=path))
+This is a foo text.
+>>> ls(cache)
+
+>>> cat(download(join(server_data, 'foo.txt'), path=path))
+This is a foo text.
+>>> ls(cache)
+
+>>> remove(path)
+
 Using namespace sub-directories of the download cache
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 



More information about the Checkins mailing list