[ZCM] [ZC] 1837/ 4 Comment "FileUpload class isn't a file"
Collector: Zope Bugs, Features,
and Patches ...
zope-coders-admin at zope.org
Thu Jul 21 12:12:47 EDT 2005
Issue #1837 Update (Comment) "FileUpload class isn't a file"
Status Resolved, Zope/bug low
To followup, visit:
http://www.zope.org/Collectors/Zope/1837
==============================================================
= Comment - Entry #4 by tino on Jul 21, 2005 12:12 pm
added next() and xreadlines() + changes.txt entry
________________________________________
= Resolve - Entry #3 by tino on Jul 21, 2005 10:03 am
Status: Accepted => Resolved
Fixed + Testcase written
in 2.8 (svn head)
in 2.7 Zope-2_7-branch
Index: HTTPRequest.py
===================================================================
--- HTTPRequest.py (Revision 37361)
+++ HTTPRequest.py (Arbeitskopie)
@@ -1422,7 +1422,8 @@
if hasattr(file, '__methods__'): methods=file.__methods__
else: methods= ['close', 'fileno', 'flush', 'isatty',
'read', 'readline', 'readlines', 'seek',
- 'tell', 'truncate', 'write', 'writelines']
+ 'tell', 'truncate', 'write', 'writelines',
+ '__iter__'] # see Collector 1837
d=self.__dict__
for m in methods:
@@ -1566,4 +1567,4 @@
# if any trusted-proxies are defined in the configuration file.
trusted_proxies = []
-
+
Index: tests/testHTTPRequest.py
===================================================================
--- tests/testHTTPRequest.py (Revision 37361)
+++ tests/testHTTPRequest.py (Arbeitskopie)
@@ -619,6 +619,17 @@
req.close()
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():
suite = unittest.TestSuite()
________________________________________
= Assign - Entry #2 by tino on Jul 21, 2005 10:00 am
Status: Pending => Accepted
Supporters added: tino
going to fix in 2.7 and 2.8
________________________________________
= Request - Entry #1 by Anonymous User on Jul 7, 2005 5:32 am
ZPublisher.HTTPRequest.FileUpload documentation says that FileUpload can be used like a file object, but doesn't implement iterator, so it can't be used sometimes, for example to import csv data:
r = csv.reader(file)
==============================================================
More information about the Zope-Collector-Monitor
mailing list