Commit 5ae156cf authored by Tino Wildenhain's avatar Tino Wildenhain

Fix FileUpload object to support iterator protocol - see collector entry #1837

parent 7e38f374
...@@ -1422,7 +1422,8 @@ class FileUpload: ...@@ -1422,7 +1422,8 @@ class FileUpload:
if hasattr(file, '__methods__'): methods=file.__methods__ if hasattr(file, '__methods__'): methods=file.__methods__
else: methods= ['close', 'fileno', 'flush', 'isatty', else: methods= ['close', 'fileno', 'flush', 'isatty',
'read', 'readline', 'readlines', 'seek', 'read', 'readline', 'readlines', 'seek',
'tell', 'truncate', 'write', 'writelines'] 'tell', 'truncate', 'write', 'writelines',
'__iter__'] # see Collector 1837
d=self.__dict__ d=self.__dict__
for m in methods: for m in methods:
...@@ -1566,4 +1567,4 @@ def _filterPasswordFields(items): ...@@ -1566,4 +1567,4 @@ def _filterPasswordFields(items):
# if any trusted-proxies are defined in the configuration file. # if any trusted-proxies are defined in the configuration file.
trusted_proxies = [] trusted_proxies = []
...@@ -619,6 +619,17 @@ class RequestTests( unittest.TestCase ): ...@@ -619,6 +619,17 @@ class RequestTests( unittest.TestCase ):
req.close() req.close()
self.assertEqual(start_count, sys.getrefcount(s)) # The test self.assertEqual(start_count, sys.getrefcount(s)) # The test
def testFileIteator(self):
# checks fileupload object supports the iterator protocol
# collector entry 1837
import sys
from StringIO import StringIO
s = StringIO(TEST_FILE_DATA)
env = TEST_ENVIRON.copy()
from ZPublisher.HTTPRequest import HTTPRequest
req = HTTPRequest(s, env, None)
req.processInputs()
self.assertEqual(list(req.form.get('file')),['test\n'])
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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