[Zope] Help on mass import of images

Sven Rudolph rudolph@medical-tribune.de
Thu, 6 Dec 2001 13:05:51 +0100


Hello,

I have a problem to import images automatically. All in all I have 2000 images to import into zope, and I tried the following method:

I created an external method "import_images.py":
>>>>>>>>>>>>
from OFS.Image import Image

def import_pictures(self):

 id='picture1'
 handle=Image(id,'','',content_type='image/gif')
 self._setObject(id,handle)
 self._getOb(id).updata_data('''TheImage''',content_type='image/gif')

 id='picture2'
 handle=Image(id,'','',content_type='image/gif')
 self._setObject(id,handle)
 self._getOb(id).updata_data('''TheImage''',content_type='image/gif')

.....and so on 
<<<<<<<<<<<<<<<<<<
I copied it to <zope-path>/Extensions, created an "External Method"-object in my image folder and then clicked on the "Test"-tab of my external method. I got two different types of errors, depending on the encoding of my image-data.
If the string "TheImage", which contains the image data, was base64 encoded, an image object was created, but the image data was broken (view tab of the image object).
If the string "TheImage" contained the pure binary data of the image (starting with GIF89a...), I got a syntax error from the parser when I tried to create the external method, as I expected.

I also tried to upload the image data with
 self._getOb(id).manage_upload('''TheImage''')
but with the same results.

Can anybody help me?


P.S. By the way: the script "import_images.py" is automatically created by a perl script.

Thanks in advance

Sven


-- 
Sven Rudolph
GermanMedicalServices.de GmbH
Unter den Eichen 5, 65195 Wiesbaden
Tel.: 06 11 / 97 46 25 2