[Zope] Resizing an Image with PIL via a Form Upload
Andrew Langmead
alangmead at boston.com
Thu Feb 22 16:11:48 EST 2007
On Feb 22, 2007, at 1:29 PM, Tom Von Lahndorff wrote:
> 8 original_image=getattr(self, original_id)
> 9 original_file=StringIO(str(original_image.data))
[and later]
> AttributeError: DSCF0004.jpg
I think your line numbers are off by one, because I'd think it is the
getattr that would be causing the Attribute Error (at most, line "9"
could give an attribute error for something called "data".
Zope turns file upload objects into
ZPublisher.HTTPRequest.FileUpload instances. and pass them to your
method. FileUpload instances have an interface similar to python file
objects, you can .read(), .seek(), .close() or do whatever you want
to them and might not need to wrap the contents into a StringIO
object first. (your trying to fetch the file as an attribute of
"self" seems to imply that you think the form data is already
uploaded into zope and is an Image object in a folder. It isn't there
yet, and won't be unless you store it there.)
I think if you removed lines 8 and 9 (by your numbering) and renamed
the second argument to the method to "original_file", things would
work as you need:
1 def makeImages(self, original_file):
2
3 import PIL.Image
4 import PIL
5 import os.path
6
...
>
More information about the Zope
mailing list