[Zodb-checkins] SVN: ZODB/branches/ctheune-blobszerocopy/src/ZODB/Blobs/ - added option to openDetached to allow hooking in the filestreamiterator

Christian Theune ct at gocept.com
Thu Mar 8 10:52:07 EST 2007


Log message for revision 73068:
   - added option to openDetached to allow hooking in the filestreamiterator
  

Changed:
  U   ZODB/branches/ctheune-blobszerocopy/src/ZODB/Blobs/Blob.py
  U   ZODB/branches/ctheune-blobszerocopy/src/ZODB/Blobs/interfaces.py

-=-
Modified: ZODB/branches/ctheune-blobszerocopy/src/ZODB/Blobs/Blob.py
===================================================================
--- ZODB/branches/ctheune-blobszerocopy/src/ZODB/Blobs/Blob.py	2007-03-08 15:51:26 UTC (rev 73067)
+++ ZODB/branches/ctheune-blobszerocopy/src/ZODB/Blobs/Blob.py	2007-03-08 15:52:07 UTC (rev 73068)
@@ -132,7 +132,7 @@
                 self._p_blob_manager.register_fh(result)
         return result
 
-    def openDetached(self):
+    def openDetached(self, class_=file):
         """Returns a file(-like) object in read mode that can be used
         outside of transaction boundaries.
 
@@ -142,7 +142,7 @@
         if self._p_blob_writers != 0:
             raise BlobError("Already opened for writing.")
         # XXX this should increase the reader number and have a test !?!
-        return file(self._current_filename(), "rb")
+        return class_(self._current_filename(), "rb")
 
     def consumeFile(self, filename):
         """Will replace the current data of the blob with the file given under

Modified: ZODB/branches/ctheune-blobszerocopy/src/ZODB/Blobs/interfaces.py
===================================================================
--- ZODB/branches/ctheune-blobszerocopy/src/ZODB/Blobs/interfaces.py	2007-03-08 15:51:26 UTC (rev 73067)
+++ ZODB/branches/ctheune-blobszerocopy/src/ZODB/Blobs/interfaces.py	2007-03-08 15:52:07 UTC (rev 73068)
@@ -27,7 +27,7 @@
         mode: Mode to open the file with. Possible values: r,w,r+,a
         """
 
-    def openDetached():
+    def openDetached(class_=file):
         """Returns a file(-like) object in read mode that can be used
         outside of transaction boundaries.
 
@@ -36,6 +36,9 @@
 
         The handle is not attached to the blob and can be used outside of a
         transaction.
+
+        Optionally the class that should be used to open the file can be
+        specified. This can be used to e.g. use Zope's FileStreamIterator.
         """
 
     def consumeFile(filename):



More information about the Zodb-checkins mailing list