Commit f7c4b516 authored by Florent Guillaume's avatar Florent Guillaume

Collector #934: Image and File objects are now always internally

split into small chunks even when initialized from a string.
parent 3e3d5cba
......@@ -34,6 +34,9 @@ Zope Changes
Bugs fixed
- Collector #934: Image and File objects are now always internally
split into small chunks even when initialized from a string.
- docutils: updated to V 0.3.5. The Zope core now contains a full copy of
the docutils package except some GPLed files which can not be included
with the Zope distribution due to license constraints on svn.zope.org.
......
......@@ -479,8 +479,10 @@ class File(Persistent, Implicit, PropertyManager,
if type(file) is StringType:
size=len(file)
if size < n: return file, size
return Pdata(file), size
elif isinstance(file, FileUpload) and not file:
# Big string: cut it into smaller chunks
file = StringIO(file)
if isinstance(file, FileUpload) and not file:
raise ValueError, 'File not specified'
if hasattr(file, '__class__') and file.__class__ is Pdata:
......
......@@ -132,6 +132,16 @@ class FileTests(unittest.TestCase):
self.assertEqual(len(s), len(str(data)))
self.assertEqual(len(s), size)
def testBigPdata(self):
# Test that a big enough string is split into several Pdata
# From a file
s = "a" * (1 << 16) * 3
data, size = self.file._read_data(StringIO(s))
self.failIfEqual(data.next, None)
# From a string
data, size = self.file._read_data(s)
self.failIfEqual(data.next, None)
def testManageEditWithFileData(self):
self.file.manage_edit('foobar', 'text/plain', filedata='ASD')
self.assertEqual(self.file.title, 'foobar')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment