[Checkins] SVN: z3c.extfile/trunk/ version bump, see CHANGES.txt

Bernd Dorn bernd.dorn at lovelysystems.com
Thu Jun 5 06:10:32 EDT 2008


Log message for revision 87162:
  version bump, see CHANGES.txt

Changed:
  U   z3c.extfile/trunk/CHANGES.txt
  U   z3c.extfile/trunk/setup.py
  U   z3c.extfile/trunk/src/z3c/extfile/filter.py
  U   z3c.extfile/trunk/src/z3c/extfile/filter.txt

-=-
Modified: z3c.extfile/trunk/CHANGES.txt
===================================================================
--- z3c.extfile/trunk/CHANGES.txt	2008-06-05 09:05:20 UTC (rev 87161)
+++ z3c.extfile/trunk/CHANGES.txt	2008-06-05 10:10:31 UTC (rev 87162)
@@ -2,6 +2,12 @@
 Changes for z3c.extfile
 =======================
 
+0.2.0b1 (2008-06-05)
+====================
+
+- initialize hashdir lazy in filter to allow deferred hashdir
+  creation.
+
 0.2.0a3 (2008-04-23)
 ====================
 

Modified: z3c.extfile/trunk/setup.py
===================================================================
--- z3c.extfile/trunk/setup.py	2008-06-05 09:05:20 UTC (rev 87161)
+++ z3c.extfile/trunk/setup.py	2008-06-05 10:10:31 UTC (rev 87162)
@@ -2,7 +2,7 @@
 
 setup(
     name = "z3c.extfile",
-    version = "0.2.0a3",
+    version = "0.2.0b1",
     author = "Zope Contributors",
     author_email = "zope3-dev at zope.org",
     description = "Large file handling for zope3",

Modified: z3c.extfile/trunk/src/z3c/extfile/filter.py
===================================================================
--- z3c.extfile/trunk/src/z3c/extfile/filter.py	2008-06-05 09:05:20 UTC (rev 87161)
+++ z3c.extfile/trunk/src/z3c/extfile/filter.py	2008-06-05 10:10:31 UTC (rev 87162)
@@ -3,22 +3,28 @@
 from cStringIO import StringIO
 import mimetypes
 import interfaces
-
+from  zope.cachedescriptors.property import Lazy
 BLOCK_SIZE = 1024*128
 
 class FSFilter(object):
 
     def __init__(self, app, directory=None):
+
         self.app = app
         if directory is not None:
             # use provided directory
             self.dir = os.path.abspath(directory)
         else:
+            self.dir = None
+
+    @Lazy
+    def hd(self):
+        if self.dir is None:
             #use environment variable
             if not os.environ.has_key('EXTFILE_STORAGEDIR'):
                 raise RuntimeError, "EXTFILE_STORAGEDIR not defined"
             self.dir = os.environ.get('EXTFILE_STORAGEDIR')
-        self.hd = hashdir.HashDir(self.dir)
+        return hashdir.HashDir(self.dir)
 
     def __call__(self, env, start_response):
         method = env.get('REQUEST_METHOD')

Modified: z3c.extfile/trunk/src/z3c/extfile/filter.txt
===================================================================
--- z3c.extfile/trunk/src/z3c/extfile/filter.txt	2008-06-05 09:05:20 UTC (rev 87161)
+++ z3c.extfile/trunk/src/z3c/extfile/filter.txt	2008-06-05 10:10:31 UTC (rev 87162)
@@ -184,3 +184,20 @@
     >>> res = app.get('/%s' % info, extra_environ=env)
     >>> res.headers
     [('content-length', '1026603'), ('content-type', 'text/plain')]
+
+Edge Cases
+==========
+
+The extfile storage directory needs to be created before the first
+request but not an initialization time.
+
+    >>> from z3c.extfile.filter import FSFilter
+    >>> f = FSFilter(None, 'nonexistent/path')
+
+The first request will try to get the lazy property .hd. This will
+fail because the directory needs to exist.
+
+    >>> f.hd
+    Traceback (most recent call last):
+    ...
+    OSError: ... No such file or directory: '.../nonexistent/path'



More information about the Checkins mailing list