Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
4d5910f3
Commit
4d5910f3
authored
Jul 23, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add better blob support to HTTPRequest.ZopeFieldStorage.
parent
e575c54b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
3 deletions
+33
-3
CHANGES.rst
CHANGES.rst
+2
-0
src/ZPublisher/HTTPRequest.py
src/ZPublisher/HTTPRequest.py
+31
-3
No files found.
CHANGES.rst
View file @
4d5910f3
...
...
@@ -14,6 +14,8 @@ Bugs Fixed
Features Added
++++++++++++++
- Add better blob support to HTTPRequest.ZopeFieldStorage.
Restructuring
+++++++++++++
...
...
src/ZPublisher/HTTPRequest.py
View file @
4d5910f3
...
...
@@ -19,10 +19,15 @@ from cgi import FieldStorage
import
codecs
from
copy
import
deepcopy
import
os
from
os
import
unlink
from
os.path
import
isfile
import
random
import
re
import
sys
import
tempfile
from
tempfile
import
(
mkstemp
,
_TemporaryFileWrapper
,
)
import
time
from
urllib
import
unquote
from
urllib
import
splittype
...
...
@@ -1601,10 +1606,33 @@ def sane_environment(env):
return
dict
class
TemporaryFileWrapper
(
_TemporaryFileWrapper
):
"""
Variant of tempfile._TemporaryFileWrapper that doesn't rely on the
automatic Windows behavior of deleting closed files, which even
happens, when the file has been moved -- e.g. to the blob storage,
and doesn't complain about such a move either.
"""
unlink
=
staticmethod
(
unlink
)
isfile
=
staticmethod
(
isfile
)
def
close
(
self
):
if
not
self
.
close_called
:
self
.
close_called
=
True
self
.
file
.
close
()
def
__del__
(
self
):
self
.
close
()
if
self
.
isfile
(
self
.
name
):
self
.
unlink
(
self
.
name
)
class
ZopeFieldStorage
(
FieldStorage
):
def
make_file
(
self
,
binary
=
None
):
return
tempfile
.
NamedTemporaryFile
(
"w+b"
)
handle
,
name
=
mkstemp
()
return
TemporaryFileWrapper
(
os
.
fdopen
(
handle
,
'w+b'
),
name
)
# Original version: zope.publisher.browser.FileUpload
...
...
@@ -1648,7 +1676,7 @@ class FileUpload:
# self.headers so that managed code can access them.
try
:
self
.
headers
.
__allow_access_to_unprotected_subobjects__
=
1
except
:
except
Exception
:
pass
def
__nonzero__
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment