Commit 8962125f authored by 's avatar

- synced formatting of FileUpload class with zope.publisher.browser.FileUpload

parent 9b67c91c
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
""" HTTP request management.
__version__='$Revision: 1.96 $'[11:-2] $Id$
"""
import re, sys, os, time, random, codecs, tempfile import re, sys, os, time, random, codecs, tempfile
from types import StringType, UnicodeType from types import StringType, UnicodeType
...@@ -1456,9 +1458,10 @@ class ZopeFieldStorage(FieldStorage): ...@@ -1456,9 +1458,10 @@ class ZopeFieldStorage(FieldStorage):
def make_file(self, binary=None): def make_file(self, binary=None):
return tempfile.NamedTemporaryFile("w+b") return tempfile.NamedTemporaryFile("w+b")
# Zope 3 version: zope.publisher.browser.FileUpload
class FileUpload: class FileUpload:
'''\ '''File upload objects
File upload objects
File upload objects are used to represent file-uploaded data. File upload objects are used to represent file-uploaded data.
...@@ -1471,28 +1474,33 @@ class FileUpload: ...@@ -1471,28 +1474,33 @@ class FileUpload:
# Allow access to attributes such as headers and filename so # Allow access to attributes such as headers and filename so
# that ZClass authors can use DTML to work with FileUploads. # that ZClass authors can use DTML to work with FileUploads.
__allow_access_to_unprotected_subobjects__=1 __allow_access_to_unprotected_subobjects__ = 1
def __init__(self, aFieldStorage): def __init__(self, aFieldStorage):
file=aFieldStorage.file file = aFieldStorage.file
if hasattr(file, '__methods__'): methods=file.__methods__ if hasattr(file, '__methods__'):
else: methods= ['close', 'fileno', 'flush', 'isatty', methods = file.__methods__
'read', 'readline', 'readlines', 'seek', else:
'tell', 'truncate', 'write', 'writelines', methods = ['close', 'fileno', 'flush', 'isatty',
'__iter__','next', 'name'] # see Collector 1837 'read', 'readline', 'readlines', 'seek',
'tell', 'truncate', 'write', 'writelines',
'__iter__','next', 'name'] # see Collector 1837
d=self.__dict__ d = self.__dict__
for m in methods: for m in methods:
if hasattr(file,m): d[m]=getattr(file,m) if hasattr(file,m):
d[m] = getattr(file,m)
self.headers=aFieldStorage.headers self.headers = aFieldStorage.headers
self.filename=aFieldStorage.filename self.filename = aFieldStorage.filename
# Add an assertion to the rfc822.Message object that implements # Add an assertion to the rfc822.Message object that implements
# self.headers so that managed code can access them. # self.headers so that managed code can access them.
try: self.headers.__allow_access_to_unprotected_subobjects__ = 1 try:
except: pass self.headers.__allow_access_to_unprotected_subobjects__ = 1
except:
pass
def __nonzero__(self): def __nonzero__(self):
"""FileUpload objects are considered false if their """FileUpload objects are considered false if their
...@@ -1503,6 +1511,7 @@ class FileUpload: ...@@ -1503,6 +1511,7 @@ class FileUpload:
def xreadlines(self): def xreadlines(self):
return self return self
parse_cookie_lock=allocate_lock() parse_cookie_lock=allocate_lock()
def parse_cookie(text, def parse_cookie(text,
result=None, result=None,
......
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