[Zope-dev] Streaming Response
Toby Dickenson
tdickenson@geminidataloggers.com
Thu, 1 May 2003 16:55:32 +0100
On Thursday 01 May 2003 4:19 pm, Shane Hathaway wrote:
> What I'm suggesting is that the storage might transparently enhance the
> application. On second thought, though, maybe that's not a good
> pattern, since it might surprise someone to find a StreamedFileData when
> they expected a SimpleFileData instance. Maybe this stuff should stay
> at the application layer.
It would be less evil if the storage exposed extra capabilities to the
application though _p_ attributes:
class SimpleFileData:
def __init__(self, bytes):
self.bytes = bytes
_p_path_to_data = None
def send(self, RESPONSE):
if self _p_path_to_data in not None:
# Hurrah! a gift from our storage
bytes = open(self._p_path_to_data, 'rb').read()
RESPONSE.write(bytes)
else:
RESPONSE.write(self.bytes)
--
Toby Dickenson
http://www.geminidataloggers.com/people/tdickenson