[Zope] python/ retrieving JPG from folder
Dragos Chirila
d.chirila at finsiel.ro
Wed Oct 20 09:45:08 EDT 2004
Hi
The LocalFile class has a method "getObject" that returns the Zope
object representing the local file. If the local file it is an image,
then getObject will return an Image object.
So in your code:
for item in context.remote.fileValues():
print item.getObject()
return printed
It will display the pictures.
But when you will need to pass the picture content use like this:
context.makethumbnail(str(item.getObject()))
Hope this will help.
Dragos
VIGNAUX Philippe wrote:
> Hi all !
>
>
>
> My zope config : Zope 2.6.4 (binary release, python2.1, win32-x86)
>
>
>
>
>
> I want to read the content of a folder (localfs) that contains pictures
> (JPG) to create thumbnails for these pictures.
>
> Nb : « remote » is the name of my zope local file system.
>
>
>
>
>
> for item in context.remote.fileValues():
>
> print item.id
>
> return printed
>
>
>
> gives as result :
>
> Chateau.jpg
>
> Paradise.jpg
>
> Which is right.
>
>
>
>
>
>
>
>
>
> for item in context.remote.fileValues():
>
> context.makethumbnail(item)
>
>
>
> gives the error message that you find below. (attribute error read)
>
>
>
> The « makethumbnail » external method has been tested and works FINE !
>
> If I give as parameter for this method the result of <input type="file"
> name= …… >, a thumnail is well created.
>
>
>
> So the problem is : what’s the right way to give the picture itself
> listed in the folder contents, as parameter in my python code ????
>
>
>
> Any help greatly appreciated !
>
>
>
> Regards,
>
>
>
> Philippe.
>
>
>
>
>
>
>
> *Exception Type*
>
>
>
> AttributeError
>
> *Exception Value*
>
>
>
> read
>
> Traceback (innermost last):
>
> * Module ZPublisher.Publish, line 98, in publish
> * Module ZPublisher.mapply, line 88, in mapply
> * Module ZPublisher.Publish, line 39, in call_object
> * Module Shared.DC.Scripts.Bindings, line 252, in __call__
> * Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
> * Module Products.PythonScripts.PythonScript, line 314, in _exec
> * Module Script (Python), line 3, in test
> *<PythonScript at /afrigeopict/test>*
> *Line 3*
> * Module Products.ExternalMethod.ExternalMethod, line 231, in __call__
> __traceback_info__: ((<LocalFile instance at 02D75CC8>,), {}, (100,))
> * Module C:\PROGRA~1\zopedb01\Extensions\thumbnail.py, line 8, in
> makethumbnail
> * Module PIL.Image, line 1547, in open
>
> AttributeError: read
>
>
>
> ###########################################
>
> This message has been scanned by ICT - Africa Museum
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
--
Dragos Chirila
Programmer, Finsiel ROMANIA
44A, Ficusului St. - 71544 Bucharest
Tel: +40 21 2320193
Fax: +40 21 2329807
URL: http://www.finsiel.ro
Jabber: dragos at jabber.finsiel.ro
More information about the Zope
mailing list