[Zope-CVS] CVS: Products/ExternalEditor - CHANGES.txt:1.25 ExternalEditor.py:1.14

Casey Duncan casey@zope.com
Thu, 18 Jul 2002 13:25:38 -0400


Update of /cvs-repository/Products/ExternalEditor
In directory cvs.zope.org:/tmp/cvs-serv9949

Modified Files:
	CHANGES.txt ExternalEditor.py 
Log Message:
Fixed bug editing large (chunked) files. They are now properly streamed


=== Products/ExternalEditor/CHANGES.txt 1.24 => 1.25 ===
 External Editor Change Log
 
+    - Fixed bug editing large (chunked) files and images. External editor now
+      streams their data properly to the client. Thanks to all the users who
+      reported various symptoms of this bug.
+
     - Fixed bug editing objects inside a Squishdot site. Thanks to Kevin Salt.
 
     - Added the capability to borrow exising DAV locks. This allows external


=== Products/ExternalEditor/ExternalEditor.py 1.13 => 1.14 ===
 from AccessControl.SecurityManagement import getSecurityManager
 from webdav.common import rfc1123_date
 from webdav import Lockable
+from OFS import Image
 
 class ExternalEditor(Acquisition.Implicit):
     """Create a response that encapsulates the data needed by the
@@ -84,6 +85,22 @@
               
         r.append('')
         
+        RESPONSE.setHeader('Pragma', 'no-cache')
+        
+        if hasattr(Acquisition.aq_base(ob), 'data') \
+           and hasattr(ob.data, '__class__') \
+           and ob.data.__class__ is Image.Pdata:
+            # We have a File instance with chunked data, lets stream it
+            metadata = join(r, '\n')
+            RESPONSE.setHeader('Content-Type', 'application/x-zope-edit')
+            RESPONSE.setHeader('Content-Length', len(metadata) + ob.get_size())
+            RESPONSE.write(metadata)
+            RESPONSE.write('\n')
+            data = ob.data
+            while data is not None:
+                RESPONSE.write(data.data)
+                data = data.next         
+            return ''
         if hasattr(ob, 'manage_FTPget'):
             try:
                 r.append(ob.manage_FTPget())
@@ -99,7 +116,5 @@
             # can't read it!
             raise 'BadRequest', 'Object does not support external editing'
         
-        RESPONSE.setHeader('Content-Type', 'application/x-zope-edit')
-        RESPONSE.setHeader('Pragma', 'no-cache')
-            
+        RESPONSE.setHeader('Content-Type', 'application/x-zope-edit')    
         return join(r, '\n')