[Zope] Errors while running the Thumbnails example code

Vlad Berditchevskiy vlad at hashbang.de
Fri Oct 8 19:16:12 EDT 2004


Hello,

i'm trying to run the example code from "The Zope Book":

http://www.plope.com/Books/2_7Edition/ScriptingZope.stx#1-5

However, there are several errors. The first error that I get is the
following:

,----
| Error Type: NameError
| Error Value: global name 'Image' is not defined
`----

I looked into the PIL tutorial and found out that they use 'import
Image' instead of 'import PIL'. I changed the import statement this way,
and this error disappeared, however I got another error, which I cannot
explain:

,----
| Error Type: AttributeError
| Error Value: StringIO instance has no attribute 'startswith'
|
| Traceback (innermost last):
| 
|     * Module ZPublisher.Publish, line 101, in publish
|     * Module ZPublisher.mapply, line 88, in mapply
|     * Module ZPublisher.Publish, line 39, in call_object
|     * Module Shared.DC.Scripts.Bindings, line 306, in __call__
|     * Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
|     * Module Products.PythonScripts.PythonScript, line 323, in _exec
|     * Module None, line 2, in makeThumbnails
|       <PythonScript at /Examples/makeThumbnails used for /Examples/Images>
|       Line 2
|     * Module Products.ExternalMethod.ExternalMethod, line 232, in __call__
|       __traceback_info__: (('4,7-liter.jpg',), {}, (200,))
|     * Module /opt/zope/instance/Extensions/Thumbnail.py, line 26, in makeThumbnail
|     * Module Image, line 1556, in open
|     * Module App.ImageFile, line 36, in __init__
|     * Module posixpath, line 60, in join
| 
| AttributeError: StringIO instance has no attribute 'startswith'
`----

This happens in the following line:

,----
| original_file=StringIO(str(original_image.data))
`----

The most strange thing about it is that if I run the following code
outside of zope, everything works:

,----
| import Image
| import StringIO
| 
| fp = open("20.jpg")
| buffer = fp.read()
| im = Image.open(StringIO.StringIO(buffer))
`----

To be sure, I tested this code in zope exactly as above (so that the
file is loaded from disk, not from Zope), but got the same error. Any
ideas, what's going wrong?

Thanks in advance!

-- 
\  /                                       vlad at hashbang.de
 \/lad                                     http://www.hashbang.de 



More information about the Zope mailing list