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
It looks to me like you're trying to upload a string: "TheImage", not data. self._getOb(id).updata_data(TheImage,content_type='image/gif') is possibly what you want. It depends what import_pictures does... Why not FTP your images into the system? You'd have to create a custom ftp PUT handler (search for hookable put). Then you could just drag and drop your images into zope. seb ----- Original Message ----- From: Sven Rudolph <rudolph@medical-tribune.de> To: <zope@zope.org> Sent: Thursday, December 06, 2001 12:05 PM Subject: [Zope] Help on mass import of images
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
I have seen this type of question almost every month on this list for 6 months. Usually the answer is use FTP or Zip or something that shy's from the challenge. I am still in the search of a better way to allow a user to select multiple images from their local system and upload them all at one time, without having to use an ftp-app or zip. A TTW (thru the web) method to enable this would be very useful. Is anyone interested in helping to build a flexible Zope product to handle this? Yes, we might have to embed python ftp functions into the method, etc, but that is why this is challenging. Anyone interested? -Trevor
On Thu, 6 Dec 2001, Sven Rudolph wrote:
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:
instead of reinventing the wheel, I'd suggest you download and install ZShell's latest version (http://cortex.unice.fr/~jerome/zshell/) and use its wget command. alternatively you could use the load_site.py script which is part of Zope's distribution. hth. Jerome Alet - alet@unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE
participants (4)
-
Jerome Alet -
Seb Bacon -
Sven Rudolph -
Trevor Toenjes