You are not logged in Log in Join
You are here: Home » Members » Stefan's Home » Patches for exUserFolder, ... » ExtFile-1.1.3ultra.patch » View File

Log in
Name

Password

 

ExtFile-1.1.3ultra.patch

File details
Size
1 K
File type
text/plain

File contents

--- ExtFile.py.orig	Fri Nov 30 00:25:32 2001
+++ ExtFile.py	Fri Nov 30 13:30:15 2001
@@ -60,8 +60,7 @@
 from DateTime import DateTime
 import urllib, os, types, string
 from os.path import join, isfile
-try: from cStringIO import StringIO
-except: from StringIO import StringIO
+import tempfile
 
 FLAT = 0
 SYNC_ZODB = 1
@@ -226,8 +225,7 @@
 		if (preview and not has_preview): icon = 1
 		
 		if icon:
-			filename = join(SOFTWARE_HOME, 'Products', 
-			                'ExtFile', self.getIconPath())
+			filename = join(Globals.package_home(globals()), self.getIconPath())
 			content_type = 'image/gif'
 		elif preview:
 			filename = self._get_filename(self.prev_filename)
@@ -241,13 +239,12 @@
 		if isfile(filename):
 			size = os.stat(filename)[6] # file size
 		else:
-			filename = join(SOFTWARE_HOME, 'Products',
-			              'ExtFile', 'icons', 'broken.gif')
+			filename = join(Globals.package_home(globals()), 'icons', 'broken.gif')
 			try: size = os.stat(filename)[6]
 			except: raise cant_read_exc, ("%s (%s)" %(self.id, filename))
 			content_type = 'image/gif'
 			icon = 1
-		data = StringIO()
+		data = tempfile.TemporaryFile()
 		if icon==0 and width is not None and height is not None:
 			try:
 				from PIL import Image
@@ -270,7 +267,17 @@
 			REQUEST.RESPONSE.setHeader('Last-Modified', last_mod)
 			REQUEST.RESPONSE.setHeader('Content-Type', content_type)
 			REQUEST.RESPONSE.setHeader('Content-Length', size)
-		return data.getvalue()
+		chunk = 1 << 18
+		data.seek(0)
+		if REQUEST is not None:
+			while 1:
+				buffer = data.read(chunk)
+				REQUEST.RESPONSE.write(buffer)
+				if len(buffer) < chunk:
+					break
+			return ''
+		else:
+			return data.read()
 	
 	def view_image_or_file(self):
 		""" The default view of the contents of the File or Image. """