Toby Dickenson wrote:
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)
I like that idea! It builds on the understanding that _p_ attributes are controlled by the database, not the application. Thanks, I'll keep that in mind. Shane