Commit d94b202e authored by Andreas Zeidler's avatar Andreas Zeidler

integrated theuni's additional test from 2.11 (see r73132)

parent 7df72923
......@@ -4,6 +4,10 @@ Zope Changes
Change information for previous versions of Zope can be found in the
file HISTORY.txt.
Blob-support branch
- Backported feature from Zope 2.11 to support named temporary files.
Zope 2.10.4 (unreleased)
Bugs fixed
......
......@@ -13,7 +13,7 @@
__version__='$Revision: 1.96 $'[11:-2]
import re, sys, os, time, random, codecs, inspect
import re, sys, os, time, random, codecs, inspect, tempfile
from types import StringType, UnicodeType
from BaseRequest import BaseRequest, quote
from HTTPResponse import HTTPResponse
......@@ -394,7 +394,7 @@ class HTTPRequest(BaseRequest):
taintedform=self.taintedform
meth=None
fs=FieldStorage(fp=fp,environ=environ,keep_blank_values=1)
fs=ZopeFieldStorage(fp=fp,environ=environ,keep_blank_values=1)
if not hasattr(fs,'list') or fs.list is None:
# Hm, maybe it's an XML-RPC
if (fs.headers.has_key('content-type') and
......@@ -1417,6 +1417,10 @@ def sane_environment(env):
except: pass
return dict
class ZopeFieldStorage(FieldStorage):
def make_file(self, binary=None):
return tempfile.NamedTemporaryFile("w+b")
class FileUpload:
'''\
......@@ -1442,7 +1446,7 @@ class FileUpload:
else: methods= ['close', 'fileno', 'flush', 'isatty',
'read', 'readline', 'readlines', 'seek',
'tell', 'truncate', 'write', 'writelines',
'__iter__','next'] # see Collector 1837
'__iter__','next', 'name'] # see Collector 1837
d=self.__dict__
for m in methods:
......
import unittest
from urllib import quote_plus
TEST_LARGEFILE_DATA = '''
--12345
Content-Disposition: form-data; name="file"; filename="file"
Content-Type: application/octet-stream
test %s
''' % ('test' * 1000)
class AuthCredentialsTestsa( unittest.TestCase ):
def _getTargetClass(self):
......@@ -684,6 +693,17 @@ class RequestTests( unittest.TestCase ):
req.close()
self.assertEqual(start_count, sys.getrefcount(s)) # The test
def testFileName(self):
# checks fileupload object supports the filename
from StringIO import StringIO
s = StringIO(TEST_LARGEFILE_DATA)
env = TEST_ENVIRON.copy()
from ZPublisher.HTTPRequest import HTTPRequest
req = HTTPRequest(s, env, None)
req.processInputs()
f = req.form.get('file')
self.assert_(f.name)
def testFileIterator(self):
# checks fileupload object supports the iterator protocol
# collector entry 1837
......
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