Returning generated gif via __getattr__
I have a gif image that I would like to return via a __getattr__ method. But I have no clues as to how I can do it. img_data # binary image data # The problem below is that it needs a docstring to get published. def __getattr__(self, attr): if attr = 'gif_image': return img_data # and if I write: def gif_image(self): "docstring" return img_data The browser does not recognise the mime type. Does anybody else have a clue as to what I need to do? regards Max M
On Mon, Nov 25, 2002 at 08:46:47PM +0100, maxm wrote:
I have a gif image that I would like to return via a __getattr__ method.
But I have no clues as to how I can do it.
img_data # binary image data
# The problem below is that it needs a docstring to get published.
def __getattr__(self, attr): if attr = 'gif_image': return img_data
See post "Method with dot in the name" some days ago: write a second method: def downlod(file, REQUEST): .... and in __getitem__: self.REQUEST["file"]=key return self.download thomas -- Thomas Guettler <guettli@thomas-guettler.de> http://www.thomas-guettler.de
On Mon, Nov 25, 2002 at 08:46:47PM +0100, maxm wrote:
I have a gif image that I would like to return via a __getattr__ method.
But I have no clues as to how I can do it.
img_data # binary image data
# The problem below is that it needs a docstring to get published.
def __getattr__(self, attr): if attr = 'gif_image': return img_data
Note that __getattr__ is already heavily used by the zope machinery. It is not easy or fun to define on your own classes. Depending on what you want to achieve, try __getitem__ or __bobo_traverse__ instead. --PW -- Paul Winkler http://www.slinkp.com "Welcome to Muppet Labs, where the future is made - today!"
participants (3)
-
maxm -
Paul Winkler -
Thomas Guettler