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
59859036
Commit
59859036
authored
Jan 10, 2005
by
Jens Vagelpohl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- forward-port DTMLMethod/filestream_iterator fix from 2.7
parent
9344f756
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/OFS/DTMLMethod.py
lib/python/OFS/DTMLMethod.py
+14
-0
lib/python/ZPublisher/Iterators.py
lib/python/ZPublisher/Iterators.py
+14
-1
No files found.
doc/CHANGES.txt
View file @
59859036
...
...
@@ -51,6 +51,9 @@ Zope Changes
Bugs fixed
- DTML Methods were not interoperable with the new filestream_iterator
and caches based on it (FileCacheManager).
- Collector #1655: fixed severe memory leak in TemporaryStorage
- Collector #1407: fixed XML escaping problem introduced in 2.7.4 b1
...
...
lib/python/OFS/DTMLMethod.py
View file @
59859036
...
...
@@ -32,6 +32,7 @@ from AccessControl.DTML import RestrictedDTML
from
Cache
import
Cacheable
from
zExceptions
import
Forbidden
from
zExceptions.TracebackSupplement
import
PathTracebackSupplement
from
ZPublisher.Iterators
import
IStreamIterator
_marker
=
[]
# Create a new marker object.
...
...
@@ -102,6 +103,19 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
if
not
self
.
_cache_namespace_keys
:
data
=
self
.
ZCacheable_get
(
default
=
_marker
)
if
data
is
not
_marker
:
if
(
IStreamIterator
.
isImplementedBy
(
data
)
and
RESPONSE
is
not
None
):
# This is a stream iterator and we need to set some
# headers now before giving it to medusa
if
RESPONSE
.
headers
.
get
(
'content-length'
,
None
)
is
None
:
RESPONSE
.
setHeader
(
'content-length'
,
len
(
data
))
if
(
RESPONSE
.
headers
.
get
(
'content-type'
,
None
)
is
None
and
RESPONSE
.
headers
.
get
(
'Content-type'
,
None
)
is
None
):
ct
=
(
self
.
__dict__
.
get
(
'content_type'
)
or
self
.
default_content_type
)
RESPONSE
.
setHeader
(
'content-type'
,
ct
)
# Return cached results.
return
data
...
...
lib/python/ZPublisher/Iterators.py
View file @
59859036
...
...
@@ -20,6 +20,13 @@ class IStreamIterator(Interface):
StopIeration if we've reached the end of the bytestream.
"""
def
__len__
(
self
):
"""
Return an integer representing the length of the object
in bytes.
"""
class
filestream_iterator
(
file
):
"""
a file subclass which implements an iterator that returns a
...
...
@@ -37,5 +44,11 @@ class filestream_iterator(file):
if
not
data
:
raise
StopIteration
return
data
def
__len__
(
self
):
cur_pos
=
self
.
tell
()
self
.
seek
(
0
,
2
)
size
=
self
.
tell
()
self
.
seek
(
cur_pos
,
0
)
return
size
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