[Zope-Checkins] SVN: Zope/branches/2.10-with-ZODB3.8/ integrated theuni's additional test from 2.11 (see r73132)

Andreas Zeidler az at zitc.de
Sun Jun 3 08:42:42 EDT 2007


Log message for revision 76209:
  integrated theuni's additional test from 2.11 (see r73132)
  

Changed:
  U   Zope/branches/2.10-with-ZODB3.8/doc/CHANGES.txt
  U   Zope/branches/2.10-with-ZODB3.8/lib/python/ZPublisher/HTTPRequest.py
  U   Zope/branches/2.10-with-ZODB3.8/lib/python/ZPublisher/tests/testHTTPRequest.py

-=-
Modified: Zope/branches/2.10-with-ZODB3.8/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10-with-ZODB3.8/doc/CHANGES.txt	2007-06-03 12:27:07 UTC (rev 76208)
+++ Zope/branches/2.10-with-ZODB3.8/doc/CHANGES.txt	2007-06-03 12:42:41 UTC (rev 76209)
@@ -4,6 +4,10 @@
   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

Modified: Zope/branches/2.10-with-ZODB3.8/lib/python/ZPublisher/HTTPRequest.py
===================================================================
--- Zope/branches/2.10-with-ZODB3.8/lib/python/ZPublisher/HTTPRequest.py	2007-06-03 12:27:07 UTC (rev 76208)
+++ Zope/branches/2.10-with-ZODB3.8/lib/python/ZPublisher/HTTPRequest.py	2007-06-03 12:42:41 UTC (rev 76209)
@@ -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 @@
         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,7 +1417,11 @@
         except: pass
     return dict
 
+class ZopeFieldStorage(FieldStorage):
 
+    def make_file(self, binary=None):
+        return tempfile.NamedTemporaryFile("w+b")
+
 class FileUpload:
     '''\
     File upload objects
@@ -1442,7 +1446,7 @@
         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:

Modified: Zope/branches/2.10-with-ZODB3.8/lib/python/ZPublisher/tests/testHTTPRequest.py
===================================================================
--- Zope/branches/2.10-with-ZODB3.8/lib/python/ZPublisher/tests/testHTTPRequest.py	2007-06-03 12:27:07 UTC (rev 76208)
+++ Zope/branches/2.10-with-ZODB3.8/lib/python/ZPublisher/tests/testHTTPRequest.py	2007-06-03 12:42:41 UTC (rev 76209)
@@ -1,6 +1,15 @@
 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 @@
         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



More information about the Zope-Checkins mailing list