Commit 0458a733 authored by Tino Wildenhain's avatar Tino Wildenhain

Refinement of collector issue 1837 - add next() and xreadlines() for a full...

Refinement of collector issue 1837 - add next() and xreadlines() for a full file interface to ZPublisher/HTTPRequest.py and appropriate test case + changes.txt entry
parent 5ae156cf
...@@ -34,6 +34,14 @@ Zope Changes ...@@ -34,6 +34,14 @@ Zope Changes
This allows to migrate interfaces to Zope 3 style interfaces and This allows to migrate interfaces to Zope 3 style interfaces and
bridge them back to oldstyle interfaces for backwards compatibility. bridge them back to oldstyle interfaces for backwards compatibility.
- ZConfig extension, address now also accepts symbolic port names
from etc/services (unix) or etc\services (win32)
- ZPublisher.HTTPRequest.FileUpload now supports full file object interface.
This means Iterator support was added. (for line in fileobject: ...,
as well as fileobject.next() and fileobject.xreadlines() )
Collector #1837
after Zope 2.8b1 after Zope 2.8b1
Features added Features added
...@@ -47,7 +55,7 @@ Zope Changes ...@@ -47,7 +55,7 @@ Zope Changes
- Collector #1844: fixed whitespace handling in the ZMI "Find" tab - Collector #1844: fixed whitespace handling in the ZMI "Find" tab
- Collector #1815: ZCTextIndex accepts (again) sequences of strings to - Collector #1815: ZCTextIndex accepts (again) sequences of strings to
be indexed. be indexed.
- Collector #1812: Fixed key error in ZSQL ZMI/Test - Collector #1812: Fixed key error in ZSQL ZMI/Test
...@@ -71,9 +79,9 @@ Zope Changes ...@@ -71,9 +79,9 @@ Zope Changes
- Collector #1803: Fixed InitializeClass for some corner case. - Collector #1803: Fixed InitializeClass for some corner case.
- Collector #1798, issue1: ZopeTestCase no longer tries to - Collector #1798, issue1: ZopeTestCase no longer tries to
install products that was installed by Zope during startup. install products that was installed by Zope during startup.
- Collector #1323: applied patch to fix umask problem in zdctl - Collector #1323: applied patch to fix umask problem in zdctl
- Collector #1781: made 'create_mount_points' ZConfig option actually - Collector #1781: made 'create_mount_points' ZConfig option actually
......
...@@ -1423,7 +1423,7 @@ class FileUpload: ...@@ -1423,7 +1423,7 @@ class FileUpload:
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 '__iter__','next'] # see Collector 1837
d=self.__dict__ d=self.__dict__
for m in methods: for m in methods:
...@@ -1443,6 +1443,8 @@ class FileUpload: ...@@ -1443,6 +1443,8 @@ class FileUpload:
""" """
return not not self.filename return not not self.filename
def xreadlines(self):
return self
parse_cookie_lock=allocate_lock() parse_cookie_lock=allocate_lock()
def parse_cookie(text, def parse_cookie(text,
......
...@@ -619,7 +619,7 @@ class RequestTests( unittest.TestCase ): ...@@ -619,7 +619,7 @@ 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): def testFileIterator(self):
# checks fileupload object supports the iterator protocol # checks fileupload object supports the iterator protocol
# collector entry 1837 # collector entry 1837
import sys import sys
...@@ -629,7 +629,12 @@ class RequestTests( unittest.TestCase ): ...@@ -629,7 +629,12 @@ class RequestTests( unittest.TestCase ):
from ZPublisher.HTTPRequest import HTTPRequest from ZPublisher.HTTPRequest import HTTPRequest
req = HTTPRequest(s, env, None) req = HTTPRequest(s, env, None)
req.processInputs() req.processInputs()
self.assertEqual(list(req.form.get('file')),['test\n']) f=req.form.get('file')
self.assertEqual(list(f),['test\n'])
f.seek(0)
self.assertEqual(f.next(),'test\n')
f.seek(0)
self.assertEqual(f.xreadlines(),f)
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