I was watching, the error occurs in globals.py:
File "/usr/home/jose/web2py/gluon/globals.py", line 204, in download
return self.stream(stream, chunk_size = chunk_size)
File "/usr/home/jose/web2py/gluon/globals.py", line 172, in stream
file_streamer = (request.env.mod_wsgi and \
AttributeError: 'NoneType' object has no attribute 'env'
def stream(
self,
stream,
chunk_size = DEFAULT_CHUNK_SIZE,
request=None,
):
"""
if a controller function::
return response.stream(file, 100)
the file content will be streamed at 100 bytes at the time
"""
if isinstance(stream, str):
stream_file_or_304_or_206(stream, request=request,
headers=self.headers)
# ## the following is for backward compatibility
if hasattr(stream, 'name'):
filename = stream.name
else:
filename = None
keys = [item.lower() for item in self.headers]
if filename and not 'content-type' in keys:
self.headers['Content-Type'] = contenttype(filename)
if filename and not 'content-length' in keys:
try:
self.headers['Content-Length'] = os.stat(filename)
[stat.ST_SIZE]
except OSError:
pass
file_streamer = (request.env.mod_wsgi and \
request.env.mod_wsgi_version >= (2,4) and
\
request.env.wsgi_file_wrapper) or
streamer
self.body = file_streamer(stream, chunk_size)
return self.body
This does work.
def stream(
self,
stream,
chunk_size=10 ** 6,
request=None,
):
"""
if a controller function::
return response.stream(file, 100)
the file content will be streamed at 100 bytes at the time
"""
if isinstance(stream, str):
stream_file_or_304_or_206(stream, request=request,
chunk_size=chunk_size, headers=self.headers)
# ## the following is for backward compatibility
if hasattr(stream, 'name'):
filename = stream.name
else:
filename = None
keys = [item.lower() for item in self.headers]
if filename and not 'content-type' in keys:
self.headers['Content-Type'] = contenttype(filename)
if filename and not 'content-length' in keys:
try:
self.headers['Content-Length'] = os.stat(filename)
[stat.ST_SIZE]
except OSError:
pass
self.body = streamer(stream, chunk_size)
return self.body
jose
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---